From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753006AbbLFA2d (ORCPT ); Sat, 5 Dec 2015 19:28:33 -0500 Received: from smtprelay0226.hostedemail.com ([216.40.44.226]:51601 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752528AbbLFA2c (ORCPT ); Sat, 5 Dec 2015 19:28:32 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2553:2559:2562:2693:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:4362:4385:5007:6261:7903:7974:10004:10400:10848:11232:11658:11914:12485:12517:12519:12663:12740:13069:13073:13311:13357:13894:14659:21080:30054:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: feet69_6763da4fd4425 X-Filterd-Recvd-Size: 2262 Message-ID: <1449361709.20344.9.camel@perches.com> Subject: Re: [PATCH] staging: speakup: kobjects.c: fix char argument to %02x From: Joe Perches To: Rasmus Villemoes Cc: William Hubbs , Chris Brannon , Kirk Reiser , Samuel Thibault , Greg Kroah-Hartman , devel@driverdev.osuosl.org, speakup@linux-speakup.org, linux-kernel@vger.kernel.org Date: Sat, 05 Dec 2015 16:28:29 -0800 In-Reply-To: <874mfwqved.fsf@rasmusvillemoes.dk> References: <1449360347-20089-1-git-send-email-linux@rasmusvillemoes.dk> <1449360735.20344.6.camel@perches.com> <874mfwqved.fsf@rasmusvillemoes.dk> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.2-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2015-12-06 at 01:21 +0100, Rasmus Villemoes wrote: > On Sun, Dec 06 2015, Joe Perches wrote: > > > On Sun, 2015-12-06 at 01:05 +0100, Rasmus Villemoes wrote: > > > If char is signed and ch happens to be negative, printing ch with > > > "%02x" will not do as intended (when ch is -19, one will get > > > "ffffffed"). Fix that by masking with 0xff. > > > > I presume there are a lot of these in the kernel. > > Did you use a tool to find this or just inspection? > > Initially I just used coccinelle, for the most obvious candidates > (with > --include-headers-for-types): > > @r depends on !patch@ > char c; > @@ > * \( sprintf \| snprintf \| scnprintf \) (..., c, ...) > > That gives lots of false positives (arguments to %c), but it's not > too > bad piping to less, searching for "%[0.]2[xX]", and then checking > manually. > > I'm now doing a much wider range of printf functions, but it's really > past my bedtime, so feel free to pick up the ball :-) > Thanks, but no thanks.  It's your ball.  Enjoy... You might consider looking for s8 and s16 emitted as %u too.