Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp9451imb; Thu, 28 Feb 2019 14:18:39 -0800 (PST) X-Google-Smtp-Source: APXvYqz/ApGVA8/CWqRpb68CatDK00uXsGPpVPK6TJqDrnJeGyRzFa9YS2z8CtM4J/znK/i+IHcH X-Received: by 2002:a62:503:: with SMTP id 3mr1950069pff.176.1551392319046; Thu, 28 Feb 2019 14:18:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551392319; cv=none; d=google.com; s=arc-20160816; b=Tbyrhr6p1qVMphIiAmgfgYePgy+/dzR5TI8gooDWAzcPqvKd5ZgUfwPaqBHyI95ZiJ h+pIADXh4CHqVe8W65MW23hNOBFkY8vXDAAMV3oxmnVb1WqGXF5VhWx2diRgvbwb9cv3 OifJdAlybXPhICszPe5BnUmTtSGjIIAfSgLi1PyQDSzbo4PkzQrs0R09JY/aPctp/O4W qzFuyaBXDaqFJbmZKNlyDpw3vZLRjb/aCWSrsZ3VFeMK62gAasn3vRtCk5wTatRNqm1G TEXBZ0+8D0srML/42xsRLOyHW/nizCD6d94OloUC+iTNaDfl50ud5/wjXCJJuEsfnSlQ fOGQ== 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:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=E1pQ/IOMp0uAFaLm7XdBfGm1RzVM6LgIMewFfLc+AXM=; b=ukSosDFIFQ464nUJV74+TdFUddNnt4abYkGtslklec0tyCdEMduP29k/Ec15vrYTKj mZtv7mEs51JjrfRCCvTiVskc7RFaxM9e6iIaQChoXKQgJfMlEtb5shpi4lokxzrVhR/R GX0YAm5ip18GXvD3nIaTVtwRaPt78VxviNgtUU+i3JYfoAGnYw973R//vPwhjrTHZbrZ Jrwyw/iaO/K6Pr6ZV71gI6x2lxP8FVY/hKxE/GhvZqLHuSTviZSa28z6bQ5HGGOgniVI sRWCVphlN1bWDB7OkChTfOCY7Tt6Lf7Fv37N7Um47giC8zR7GYtpcccphPmln1/cl8Os qdUQ== 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 r15si17362245pgv.389.2019.02.28.14.18.16; Thu, 28 Feb 2019 14:18:39 -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 S1728223AbfB1Vxg (ORCPT + 99 others); Thu, 28 Feb 2019 16:53:36 -0500 Received: from smtprelay0117.hostedemail.com ([216.40.44.117]:43535 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726087AbfB1Vxg (ORCPT ); Thu, 28 Feb 2019 16:53:36 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 8B157100E86C1; Thu, 28 Feb 2019 21:53:35 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:69:355:379:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3867:3871:4321:5007:7557:8603:10004:10400:10848:11232:11658:11914:12043:12296:12555:12740:12760:12895:12986:13095:13439:14659:14721:21080:21433:21451:21611:21627:30054:30091,0,RBL:172.58.19.222:@perches.com:.lbl8.mailshell.net-62.8.0.180 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:29,LUA_SUMMARY:none X-HE-Tag: sack82_7660e8beb3f32 X-Filterd-Recvd-Size: 3143 Received: from XPS-9350 (unknown [172.58.19.222]) (Authenticated sender: joe@perches.com) by omf06.hostedemail.com (Postfix) with ESMTPA; Thu, 28 Feb 2019 21:53:33 +0000 (UTC) Message-ID: <15c6689389503a82394bccb9204650bf20a7a6d3.camel@perches.com> Subject: Re: [PATCH v2] wusb: use correct format characters From: Joe Perches To: Louis Taylor , gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, ndesaulniers@google.com, jflat@chromium.org Date: Thu, 28 Feb 2019 13:53:31 -0800 In-Reply-To: <20190228122417.9318-1-louis@kragniz.eu> References: <20190228115256.5446-1-louis@kragniz.eu> <20190228122417.9318-1-louis@kragniz.eu> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.1-1build1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-02-28 at 12:24 +0000, Louis Taylor wrote: > When compiling with -Wformat, clang warns: > ./include/linux/usb/wusb.h:245:5: warning: format specifies type > 'unsigned short' but the argument has type 'u8' (aka 'unsigned char') > [-Wformat] > ckhdid->data[0], ckhdid->data[1], > ^~~~~~~~~~~~~~~ I think the message is somewhat misguided as all the vararg arguments have implicit integer promotions. > ckhdid->data is unconditionally defined as `u8 data[16]`, so this patch > updates the format characters to the correct one for unsigned char types. [] > diff --git a/include/linux/usb/wusb.h b/include/linux/usb/wusb.h [] > @@ -240,8 +240,8 @@ static inline size_t ckhdid_printf(char *pr_ckhdid, size_t size, > const struct wusb_ckhdid *ckhdid) > { > return scnprintf(pr_ckhdid, size, > - "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx " > - "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx", > + "%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx " > + "%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx", > ckhdid->data[0], ckhdid->data[1], > ckhdid->data[2], ckhdid->data[3], > ckhdid->data[4], ckhdid->data[5], Better to use the vsprintf %ph extension insead. --- include/linux/usb/wusb.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/include/linux/usb/wusb.h b/include/linux/usb/wusb.h index 9e4a3213f2c2..8c39ddf62951 100644 --- a/include/linux/usb/wusb.h +++ b/include/linux/usb/wusb.h @@ -239,17 +239,7 @@ enum { static inline size_t ckhdid_printf(char *pr_ckhdid, size_t size, const struct wusb_ckhdid *ckhdid) { - return scnprintf(pr_ckhdid, size, - "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx " - "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx", - ckhdid->data[0], ckhdid->data[1], - ckhdid->data[2], ckhdid->data[3], - ckhdid->data[4], ckhdid->data[5], - ckhdid->data[6], ckhdid->data[7], - ckhdid->data[8], ckhdid->data[9], - ckhdid->data[10], ckhdid->data[11], - ckhdid->data[12], ckhdid->data[13], - ckhdid->data[14], ckhdid->data[15]); + return scnprintf(pr_ckhdid, size, "%16ph", ckhdid->data); } /*