From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753205AbbLFAVf (ORCPT ); Sat, 5 Dec 2015 19:21:35 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:34968 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753097AbbLFAVd (ORCPT ); Sat, 5 Dec 2015 19:21:33 -0500 From: Rasmus Villemoes To: Joe Perches 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 Subject: Re: [PATCH] staging: speakup: kobjects.c: fix char argument to %02x Organization: D03 References: <1449360347-20089-1-git-send-email-linux@rasmusvillemoes.dk> <1449360735.20344.6.camel@perches.com> X-Hashcash: 1:20:151206:joe@perches.com::UZsys5OPKDMsC7L+:00035V X-Hashcash: 1:20:151206:devel@driverdev.osuosl.org::Tg048ubfuLv4t63G:000000000000000000000000000000000001ZvC X-Hashcash: 1:20:151206:chris@the-brannons.com::g54XKx0l9by4HZFz:0000000000000000000000000000000000000003WGU X-Hashcash: 1:20:151206:linux-kernel@vger.kernel.org::SGI3yciwRAtYcK5b:00000000000000000000000000000000031o9 X-Hashcash: 1:20:151206:gregkh@linuxfoundation.org::vsSoH7BM1soDWXC7:000000000000000000000000000000000004FxF X-Hashcash: 1:20:151206:w.d.hubbs@gmail.com::60JTBzjOtUG2rtWu:0000000000000000000000000000000000000000005Oij X-Hashcash: 1:20:151206:kirk@reisers.ca::0gmSAptdvWj0h9az:008y4/ X-Hashcash: 1:20:151206:samuel.thibault@ens-lyon.org::kIKBVoj23t116rAc:0000000000000000000000000000000007pkh X-Hashcash: 1:20:151206:speakup@linux-speakup.org::iTlM65IMe5D1RtwI:000000000000000000000000000000000000Eb3K Date: Sun, 06 Dec 2015 01:21:30 +0100 In-Reply-To: <1449360735.20344.6.camel@perches.com> (Joe Perches's message of "Sat, 05 Dec 2015 16:12:15 -0800") Message-ID: <874mfwqved.fsf@rasmusvillemoes.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 :-) Rasmus