Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp36861imb; Thu, 28 Feb 2019 15:12:49 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibv1nXUYlp81p2AJG1NqCTFRGvPUsdGZShz3mfLD9dyw9NTo/136TcjbV/WNlViYApgUiZj X-Received: by 2002:aa7:9255:: with SMTP id 21mr2260982pfp.8.1551395569534; Thu, 28 Feb 2019 15:12:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551395569; cv=none; d=google.com; s=arc-20160816; b=Sgc5sfYys8OR7Bzol2Mi6r1NBe1JwZCRbKe6+rrIRwnJDN3t8LY/nyeYawCdnrLkUP zT0um9h+pxK7eHaoEPg8Y+emuXngbo0lnC/3DigQ6ZlxT1kPgGvrxWEE4Fcx1TBMPGe9 3/13H9sHRLQUxbdxZ+3BZ9zJfhEML7ekU7StTW9vap8TwcmLePjXa+Gxtpp14u8IOMCF nup4bnLUPIe0luNseaa7PsG0UdYKXzSEt5Sf6txEMa++xvC77FZgiWCGw98SSLhNyFPp YYM6p3YYxvivALDauDCLtXNzGDxVY9sFvYXPGxzbTS/Jh1N0rxLWmGIfdMU1IWb2lyYC JaLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=5RAd0QQZng4fQskE3CujPczUuxrVI753C7t/+NAS6As=; b=MfbweWo5johIm9W8dbDi3iG5rn+HEsE9+FGsbuMn6j+fM3COe9s0dQKS6gdTrqTcwd dsVLpXe7ZB1mhzfJb4l+gxkYwWEQVmEEozUFsDhrO6qfBcbq8fgiAkqIj2665e895coF wUO2Ue5XbxSicZDRi+92CzcLAlwFKEtIklVbdMp71Xkv6motQ41Pi3bpeX52dRjsr5HZ nPBaQnwJKSiaIoQYYybMNj6JBzqBAilOot5tnm+7TpihLlS3XAg9mHEXdPZ8hJpJJzfl ZgPcz8FRKpEBItA9eJjcwRcYHemxFdePycq4tK2JBq0U2Gd6LmAkNbePDoeWybckxUJg HFJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dBKAKjqM; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si19294811plb.375.2019.02.28.15.12.19; Thu, 28 Feb 2019 15:12:49 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=dBKAKjqM; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732989AbfB1TTW (ORCPT + 99 others); Thu, 28 Feb 2019 14:19:22 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46153 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730991AbfB1TTW (ORCPT ); Thu, 28 Feb 2019 14:19:22 -0500 Received: by mail-pf1-f193.google.com with SMTP id g6so10163077pfh.13 for ; Thu, 28 Feb 2019 11:19:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5RAd0QQZng4fQskE3CujPczUuxrVI753C7t/+NAS6As=; b=dBKAKjqMErhfgXV+Sw1KhwV50LL2uEjl54KDmB2Fs2U7dVgR+oZOBaKbKG0mBkPvXY 7EoYFex+11gKgwi6pb5MK27KFZhm5EUtarsq9Uiz5wTHbgZPoKW1iOV0TPYPHlCmYQiL uLuNOMjis5xmRZAYtDxysNXIRbNpr5VoEhpN7hxrysWhX4cIkk0trUdfFVx4GqMZVzXx PmNC4OJA1jbVcWia87gUAbmNixMeG1NFxtISv+aoRWsxqgJx+pazk2S4Cl5wgRVufMTG /KW5sTgf2aCdEkqzG3RVEvUsElPYBAlKEzl0GUlgK/dnkefJ/Tb1Au1i/IEDOIfUpQAD jNzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5RAd0QQZng4fQskE3CujPczUuxrVI753C7t/+NAS6As=; b=NzzGWQNC8fFI6I5xdB5m/Kj9xf7EkDqfCsFW7ImnCAMSgf+HYPT0GIKdECz3Kq54No sxHi8rnzDtSmXJ6QVtwREIgdEpQB9f06W99dmoN53jDrLVcHTDH86zD1cftwp/1fNBD8 1KUM0cHYChZuxqQzlHVWgVD3QXWq5NIn2oCxvmzY0NxhAkUvdzexkjuVGofRwZBa5zkx KNykjHnoypSKKSE0ARFLY3xUNfWpJvNmmVkKsXLeiUwUBGLbIchScn40xWS0hxfz/YPP 5M7j1OZEZNtb0MT9mFW/oIzKOse7NJRc7hZDJrbUIdqed3w6+TB4JAm/fpA1P/+UoR4I WZLQ== X-Gm-Message-State: APjAAAV5UCpPbj3phRfNCi2v28wXyyK4TTLLy9xRCXTIKFNZNVr4//SO V2zGp/gbI9J7Fo94Zl62U8rQH3hKnyk6W8oPo8AunQ== X-Received: by 2002:a62:2b88:: with SMTP id r130mr1172498pfr.93.1551381560963; Thu, 28 Feb 2019 11:19:20 -0800 (PST) MIME-Version: 1.0 References: <20190228115256.5446-1-louis@kragniz.eu> <20190228122417.9318-1-louis@kragniz.eu> In-Reply-To: <20190228122417.9318-1-louis@kragniz.eu> From: Nick Desaulniers Date: Thu, 28 Feb 2019 11:19:09 -0800 Message-ID: Subject: Re: [PATCH v2] wusb: use correct format characters To: Louis Taylor , Greg KH Cc: linux-usb@vger.kernel.org, LKML , clang-built-linux@googlegroups.com, Jon Flatley , Stephen Hines , inaky.perez-gonzalez@intel.com, david.vrabel@csr.com, Miguel Ojeda Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 28, 2019 at 4:28 AM 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') We should probably update Documentation/core-api/printk-formats.rst to list [u|s][8|16] printk formats so that I don't have to go read lib/vsprintf.c#format_decode(). (TODO in a separate patch) > [-Wformat] > ckhdid->data[0], ckhdid->data[1], > ^~~~~~~~~~~~~~~ > > ckhdid->data is unconditionally defined as `u8 data[16]`, so this patch > updates the format characters to the correct one for unsigned char types. > > Link: https://github.com/ClangBuiltLinux/linux/issues/378 > Signed-off-by: Louis Taylor > --- > include/linux/usb/wusb.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/linux/usb/wusb.h b/include/linux/usb/wusb.h > index 9e4a3213f2c2..625366d3499e 100644 > --- 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", Looks like lib/vsprintf.c#format_decode() accepts either %hh or %H for lone unsigned bytes, IIUC. Thanks for the patch and for following up on the feedback. Reviewed-by: Nick Desaulniers I wonder if __attribute__((packed)) is needed on the definition of `struct wusb_ckhdid`? hmm... via Stephen: https://godbolt.org/z/vs5JNo Looks like alignof(struct wusb_ckhdid) is 1. And struct wusb_ckhdid was introduced as is in commit c7f736484f8e ("wusb: add the Wireless USB include files.") so it's not like it ever had additional members that would disturb the alignment. `__aligned(__alignof__(u8))` might be clearer than `__attribute__((packed))`, but even then, I don't think anything is necessary since the alignof should always be 1? > ckhdid->data[0], ckhdid->data[1], > ckhdid->data[2], ckhdid->data[3], > ckhdid->data[4], ckhdid->data[5], > -- > 2.20.1 > -- Thanks, ~Nick Desaulniers