Received: by 10.223.176.5 with SMTP id f5csp490219wra; Tue, 6 Feb 2018 02:25:21 -0800 (PST) X-Google-Smtp-Source: AH8x227QEOfg1jmvyc4MC2rxS5tEEzEjNJ5/ibIyicYbsBzQNpoyDb0eGdllHUb/cXWHIJppsnop X-Received: by 2002:a17:902:328:: with SMTP id 37-v6mr1987029pld.398.1517912721525; Tue, 06 Feb 2018 02:25:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517912721; cv=none; d=google.com; s=arc-20160816; b=OuL64wPiwF23CnnMhpyEdIRxok7NS9Urnc3Pf8uCmYAtpoOD2c6E8D2ahSkhM2Hjgt ZT69Of+KKeGErA6O1qvYqm8kn+X13TFNNmaFATAQQ1B703o/Gnl7/wAPEhBpXaKLbXd2 qgkGbdgpbuLN15Pr+fRoZCSY27wxiGYGqwTNMjkImdwxR2jCsqcOBTrKOLJteBSrdmIv y7447b6rajouZaC52gsDJ3lt+BKwmbOTygPJ42nBFwwIDkD33vWM4v5UhlCN1Sl1j5Dg Hi676vyvBwBJTVxsX3JXoNu3OKu44maQcQChTw7W9bJsXFLmLSJKeMNiKbzs1BUssHIt mN9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=yHbmBveD5LyoS2OwKeKdkg7JPFYiraUj7775SFRDQWo=; b=0dA2cj7NcKdNzWNljtu0R7rGIIGWP20YVffwwN00s3Ml4fo6Nj72KxSzqYwwXQxvjk pJGtJcbtKH7aoCquf9CMrFC/1Nb5IQof1rfq1wOGOTMsXJHlQStEgptEMpUttoARKtmh rjP5+VZm46u/FW/DJsEq13t6y4IA6+kVv1xdF4JLTanW7ePtOWFUNLRs8ps+HAh8LLky oxGW9HuuJMTcgVAtpVHDm2DU4DJE/oadsT1ZhwL74F46F2RgP9UOoR+fex1UQRrM8CWA nngrF5GHW9cU3aAzbkU7zJNPvuElStK+P67rrqA+ahmDEBFWzNfwEPwH9IOWH43vT5Mz h0ow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z20-v6si1064263plo.73.2018.02.06.02.25.07; Tue, 06 Feb 2018 02:25:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752715AbeBFKYd (ORCPT + 99 others); Tue, 6 Feb 2018 05:24:33 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41330 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752187AbeBFKYY (ORCPT ); Tue, 6 Feb 2018 05:24:24 -0500 Received: from localhost (unknown [209.136.236.94]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 28CAEF5C; Tue, 6 Feb 2018 10:24:24 +0000 (UTC) Date: Tue, 6 Feb 2018 02:24:21 -0800 From: Greg KH To: "Srivatsa S. Bhat" Cc: logang@deltatee.com, axboe@kernel.dk, jlayton@poochiereds.net, bfields@fieldses.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] block, char_dev: Use correct format specifier for unsigned ints Message-ID: <20180206102421.GC7889@kroah.com> References: <151788389652.28069.6065922071875812126.stgit@srivatsa-ubuntu> <151788391701.28069.13145257664735983272.stgit@srivatsa-ubuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151788391701.28069.13145257664735983272.stgit@srivatsa-ubuntu> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 05, 2018 at 06:25:27PM -0800, Srivatsa S. Bhat wrote: > From: Srivatsa S. Bhat > > register_blkdev() and __register_chrdev_region() treat the major > number as an unsigned int. So print it the same way to avoid > absurd error statements such as: > "... major requested (-1) is greater than the maximum (511) ..." > (and also fix off-by-one bugs in the error prints). > > While at it, also update the comment describing register_blkdev(). > > Signed-off-by: Srivatsa S. Bhat > --- > > block/genhd.c | 19 +++++++++++-------- > fs/char_dev.c | 4 ++-- > 2 files changed, 13 insertions(+), 10 deletions(-) > > diff --git a/block/genhd.c b/block/genhd.c > index 88a53c1..21a18e5 100644 > --- a/block/genhd.c > +++ b/block/genhd.c > @@ -308,19 +308,22 @@ void blkdev_show(struct seq_file *seqf, off_t offset) > /** > * register_blkdev - register a new block device > * > - * @major: the requested major device number [1..255]. If @major = 0, try to > - * allocate any unused major number. > + * @major: the requested major device number [1..BLKDEV_MAJOR_MAX-1]. If > + * @major = 0, try to allocate any unused major number. > * @name: the name of the new block device as a zero terminated string > * > * The @name must be unique within the system. > * > * The return value depends on the @major input parameter: > * > - * - if a major device number was requested in range [1..255] then the > - * function returns zero on success, or a negative error code > + * - if a major device number was requested in range [1..BLKDEV_MAJOR_MAX-1] > + * then the function returns zero on success, or a negative error code > * - if any unused major number was requested with @major = 0 parameter > * then the return value is the allocated major number in range > - * [1..255] or a negative error code otherwise > + * [1..BLKDEV_MAJOR_MAX-1] or a negative error code otherwise > + * > + * See Documentation/admin-guide/devices.txt for the list of allocated > + * major numbers. > */ > int register_blkdev(unsigned int major, const char *name) > { > @@ -347,8 +350,8 @@ int register_blkdev(unsigned int major, const char *name) > } > > if (major >= BLKDEV_MAJOR_MAX) { > - pr_err("register_blkdev: major requested (%d) is greater than the maximum (%d) for %s\n", > - major, BLKDEV_MAJOR_MAX, name); > + pr_err("register_blkdev: major requested (%u) is greater than the maximum (%u) for %s\n", > + major, BLKDEV_MAJOR_MAX-1, name); > > ret = -EINVAL; > goto out; > @@ -375,7 +378,7 @@ int register_blkdev(unsigned int major, const char *name) > ret = -EBUSY; > > if (ret < 0) { > - printk("register_blkdev: cannot get major %d for %s\n", > + printk("register_blkdev: cannot get major %u for %s\n", > major, name); > kfree(p); > } > diff --git a/fs/char_dev.c b/fs/char_dev.c > index 33c9385..a279c58 100644 > --- a/fs/char_dev.c > +++ b/fs/char_dev.c > @@ -121,8 +121,8 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, > } > > if (major >= CHRDEV_MAJOR_MAX) { > - pr_err("CHRDEV \"%s\" major requested (%d) is greater than the maximum (%d)\n", > - name, major, CHRDEV_MAJOR_MAX); > + pr_err("CHRDEV \"%s\" major requested (%u) is greater than the maximum (%u)\n", > + name, major, CHRDEV_MAJOR_MAX-1); > ret = -EINVAL; > goto out; > } Thanks for both of these patches, if Al doesn't grab them, I will after 4.16-rc1 comes out. greg k-h