Received: by 10.223.176.5 with SMTP id f5csp1063571wra; Tue, 6 Feb 2018 11:59:43 -0800 (PST) X-Google-Smtp-Source: AH8x227/Huppla7nEAw7HrMcRUQ4G+4ULQ6QHEXshkGnvkyVuZcfVtDM4FKwY066RfvU3yKSRS+s X-Received: by 10.101.72.197 with SMTP id o5mr2848492pgs.303.1517947182959; Tue, 06 Feb 2018 11:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517947182; cv=none; d=google.com; s=arc-20160816; b=fHeJ0EkWfozI3iduD2L7/+Eup4CFOHdqhxQ69I4L7fykPDWFr23EIKRk/3ut1nQLef r+nHOAnuvCVcWaSgsJnzAp2nqwRkMwG6O2L5H/uYi4qDB4jCXQwA/ddOiGwQV9HaaW2C bRXZPqyQ8Y7G+/mp4cnAqrGHVW1l6lV1pBsDZMdLwtKcOPo4EfGUbt0qx9DCBQtpYJn4 aa+dsZ1RRuT9YzWoFYsrD+xYuPpx0FeLWV/ephtDHQgLn54PKBlAvWhMsWWas5gR8HD/ Fy11bvpPghh2gTOrnZIe21xbvKXS6ta3NzYKpcaxt2mZ10ssjGDfEXUoONOrk//9yZpG P4ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=etizBiUAgk/58Uu+aljHkg7VB9Mh6CH+zOM2XhUW+H4=; b=CR5FQcPI1dvw2SLZ2P1zrIZ90CgItFCnXFZ7Z6tf9jQneoqdbmLQJoeSLrtkuKCKjx eDh6+VP3im0rWueXtoW4WjbS6XJIu0Kzkz1JHKtcthQBRVyMB1cNEDbd/kAcgUwmMkGz tohEUGXpHUD/+6LnE+qs/2FkpE8oP+YZUbYkNFQDyIAzyCZVXqbpp5sB3lkBMOYxSwIN OlHtirW3aftnhG10SGlK9MRtDXG4JVyKsiXCgLKjwIFWKxJZiLAF8Gv2ghA3g4Ku6o8f /gYq/uuuyiKYjh3r0XaT8e5tZWAa8R68EdmvaCHs6iL7SzXZvp7G8UBOv4X3SsOt3jvy uf2w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=csail.mit.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j69si7140980pgd.643.2018.02.06.11.59.28; Tue, 06 Feb 2018 11:59:42 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=csail.mit.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752726AbeBFT6q (ORCPT + 99 others); Tue, 6 Feb 2018 14:58:46 -0500 Received: from outgoing-stata.csail.mit.edu ([128.30.2.210]:58921 "EHLO outgoing-stata.csail.mit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751555AbeBFT6o (ORCPT ); Tue, 6 Feb 2018 14:58:44 -0500 Received: from 67-148-5-85.dia.static.qwest.net ([67.148.5.85] helo=srivatsab-m01.vmware.com) by outgoing-stata.csail.mit.edu with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1ej9O2-000OZc-ER; Tue, 06 Feb 2018 14:58:38 -0500 Subject: Re: [PATCH 2/2] block, char_dev: Use correct format specifier for unsigned ints To: Greg KH 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 References: <151788389652.28069.6065922071875812126.stgit@srivatsa-ubuntu> <151788391701.28069.13145257664735983272.stgit@srivatsa-ubuntu> <20180206102421.GC7889@kroah.com> From: "Srivatsa S. Bhat" Message-ID: <4ed3b9d5-ea65-ef7d-6377-62aeae44c5a3@csail.mit.edu> Date: Tue, 6 Feb 2018 11:58:36 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180206102421.GC7889@kroah.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/6/18 2:24 AM, Greg KH wrote: > 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. > Sounds great! Thank you! Regards, Srivatsa