Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp726212pxj; Fri, 28 May 2021 14:13:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgkp0kzbIMqm/C2bB6AFeFTLFlc8hi6x/NZamfft2PhZ2NeBVoUMbb0Mg9WuIsjFkJ6jxE X-Received: by 2002:a17:906:bcd6:: with SMTP id lw22mr11165762ejb.250.1622236418588; Fri, 28 May 2021 14:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622236418; cv=none; d=google.com; s=arc-20160816; b=vs2qPAzyDGPsiVWmYCgX5RNbwki3blyMIQZH0dMO3GEkbg+tO6rnJi8e0mYoNJvMKG wrsb3SU+StAbkaiNWxxa0UpOt1akz8EXncTm56tHtI0CztUtedIb8p9gIsBXDmK7rKuS vDT9a9XBU3iZDSWyEPP/mz66hUSPfXRwpw8Z/h1Qqf4g4PEJlNir3MhIzsNuIkxQ4vSj Hn+ZJlXfQpTBpcogZHRSsod8eh++5yDle1PvsqEqrqSgMzlRliEppJKqjD0Ie7PjUhSS NiqGtszfBnj5kJGbF2wP4T8RbGtt3gV3wsnuAJ8Q88nIA4S3ek9LmJj9nFYF2NNcgzbP gsdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=OvJNJ7Sx8yHc2xCji7KEYVjRv5OoIu+RxTe4lv2pNvg=; b=e5oNcmO8FFqnWGFT1+EcGVzyUAgt06z977Xh/640QcUZV9Tanzb/Xi3v8SLAy1nadh 2AiuW90EOUuasqZvYGqOTmKFIX6VaUAoCo+AY1M1Y7PUpZjsPJj82xUS8qk7xzD3KVio /vHFZG4wdMf4fLNJLvLKOsN0hA/QzF1hzkZBpdHuhSyCy5cQzqTdYkhtIbki3Pewe81k NsTRPv8x05brrK95AjI47l5HzEL8VQgF1KOWeMp/jKxpf9TM2kIU5vnA2KemZsAJ7BQk 3XKJudUmhwXSTqIpP+pD/UbDi+K098Zp+JayNz7Do8CgSwQ9ma0FEtaT6QdTzCO2uv2B OBZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q23si5724996ejj.340.2021.05.28.14.13.14; Fri, 28 May 2021 14:13:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229565AbhE1VLo (ORCPT + 99 others); Fri, 28 May 2021 17:11:44 -0400 Received: from smtprelay0059.hostedemail.com ([216.40.44.59]:47408 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229481AbhE1VLn (ORCPT ); Fri, 28 May 2021 17:11:43 -0400 Received: from omf01.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id BA90A181D337B; Fri, 28 May 2021 21:10:07 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf01.hostedemail.com (Postfix) with ESMTPA id 74EA217275; Fri, 28 May 2021 21:10:05 +0000 (UTC) Message-ID: Subject: Re: [PATCH] iio: si1133: fix format string warnings From: Joe Perches To: Andy Shevchenko Cc: Jonathan Cameron , Nathan Chancellor , Arnd Bergmann , Nick Desaulniers , Maxime =?ISO-8859-1?Q?Roussin-B=E9langer?= , Jean-Francois Dagenais , Arnd Bergmann , Lars-Peter Clausen , Alexandru Ardelean , "linux-iio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "clang-built-linux@googlegroups.com" Date: Fri, 28 May 2021 14:10:04 -0700 In-Reply-To: References: <20210514135927.2926482-1-arnd@kernel.org> <7afc367b-8103-9d48-1bfe-d505d86553b9@kernel.org> <20210516103628.2cf899a0@jic23-huawei> <644a711e4d2639a23bfc50dffa180ad184a4acb1.camel@perches.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.40 X-Stat-Signature: 5acgrz7aqqahef7j4xfkx1oihty81c8i X-Rspamd-Server: rspamout04 X-Rspamd-Queue-Id: 74EA217275 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19u0+cg/CvkDoccaPXMZBb1xXuLYIiXf/A= X-HE-Tag: 1622236205-755196 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-05-28 at 23:59 +0300, Andy Shevchenko wrote: > On Thursday, May 27, 2021, Joe Perches wrote: > > On Sun, 2021-05-16 at 10:36 +0100, Jonathan Cameron wrote: > > > On Fri, 14 May 2021 10:45:02 -0700 > > > Nathan Chancellor wrote: > > > > On 5/14/2021 6:59 AM, Arnd Bergmann wrote: > > > > > From: Arnd Bergmann > > > > > > > > > > clang complains about multiple instances of printing an integer > > > > > using the %hhx format string: > > > > > > > > > > drivers/iio/light/si1133.c:982:4: error: format specifies type > > 'unsigned char' but the argument has type 'unsigned int' [-Werror,-Wformat] > > > > >                   part_id, rev_id, mfr_id); > > > > >                   ^~~~~~~ > > > > > > > > > > Print them as a normal integer instead, leaving the "#02" > > > > > length modifier. > > [] > > > > > diff --git a/drivers/iio/light/si1133.c b/drivers/iio/light/si1133.c > > [] > > > > > @@ -978,11 +978,11 @@ static int si1133_validate_ids(struct iio_dev > > *iio_dev) > > > > >                   return err; > > > > > > > > > > > > > > >           dev_info(&iio_dev->dev, > > > > > - "Device ID part %#02hhx rev %#02hhx mfr %#02hhx\n", > > > > > + "Device ID part %#02x rev %#02x mfr %#02x\n", > > > > >                    part_id, rev_id, mfr_id); > > > > >           if (part_id != SI1133_PART_ID) { > > > > >                   dev_err(&iio_dev->dev, > > > > > - "Part ID mismatch got %#02hhx, expected %#02x\n", > > > > > + "Part ID mismatch got %#02x, expected %#02x\n", > > > > which is almost certainly wrong. > > the length specification includes the # which is already 2 bytes. > > > > Likely these should be 0x%02x > > What’s the difference (except printing 0)? (assuming the argument is unsigned char/u8) %#02x will always emit more than the specified length (3 or 4 chars) values < 16 are 0x, values >= 16 are 0x 0x%02x will always emit 4 chars It's very likely the writer didn't know the difference and assumed that the # did not count in the specified width.