Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5282963yba; Wed, 10 Apr 2019 15:54:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiblCu0dQch+P60b2bdWcZ6YGB7bU43BNwO1ytem+hC8fU7hOgX0EKn7z66JsWwBnvzPtP X-Received: by 2002:aa7:9296:: with SMTP id j22mr47055785pfa.140.1554936860232; Wed, 10 Apr 2019 15:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554936860; cv=none; d=google.com; s=arc-20160816; b=L4xJjBdvWvOYn1VVxbUdR+Yjko0rFyzpysICgKepmycGQ3I3p5mkxAa+/YOXyJLLxj hgjKO2jOZiT+qyfItQqtFyQEt5CG6wf3wpnEd0u0tsUSZpHd8UTVJ/ErbYrA65oha1Bw MC31uqtCDbpwCZhYyZainOwSdFKtvWM/Z9d8EHmCWZKoyKmqGmngASj8LO8cdkhx3xzB txQRgXht3V4h9bu2GvUrA9TeXKt0btm8b0HkBRoWUSiRIJbCMJDXgoiYLhIBMNhRx2uc REIwge3dacySSNABkokGXfj8qjHxF18AErnRrGgQ/VRKqMuQlzQL12pLtwByaYGPgx8/ IIXg== 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=tgu9rCUlCUyRg9pTWOOFz0QLkS3psF0id2QKUuVnVNU=; b=LMoBCVN4XFCtRNGgDdPfshjmVvCq2emx0rq01pcs4qd2mYouYzFm0sE96LcK91zkQD MitqolNyd2/ljK0LQMhbsr4aIhLhRe9nxRlJ88KE/kuP+9pwCFl6k2aYoRZqQBVtQj7B uy/Xz+05cKbP3p/47ktJYduNbRqisOwXgF/eEPPjIwKuV8b62jTxhVEqf2mzHHI3k57J 4LjksrXYRcuwAm1HIOhpcK/rZSyF/aqNhSZLjRkyN7rzu2jjRk52ome5hxikVS/+bbIn IPftCMKfhGJUJNhCGLz6WvnN81Ww9bN0abzJd2VEjbvphQJdwY+UIcd0hwKuoWhzQSEY YN0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=H3gdf1SC; 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 a192si14819007pge.50.2019.04.10.15.54.04; Wed, 10 Apr 2019 15:54:20 -0700 (PDT) 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=H3gdf1SC; 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 S1726783AbfDJWwj (ORCPT + 99 others); Wed, 10 Apr 2019 18:52:39 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37974 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726723AbfDJWwh (ORCPT ); Wed, 10 Apr 2019 18:52:37 -0400 Received: by mail-pl1-f195.google.com with SMTP id f36so2298713plb.5 for ; Wed, 10 Apr 2019 15:52:37 -0700 (PDT) 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=tgu9rCUlCUyRg9pTWOOFz0QLkS3psF0id2QKUuVnVNU=; b=H3gdf1SCfcoUCCXHTroS7uP9CcD5D65nMUz7Fh7Mw2sAhS5Qq+jSkCOdMV6YcYCZy2 cxLhWFA3JvVmMoWX6tNXrM1vZDPcul0o7S0F2cT1AYp8dzNdaffpc968qOEkGObRAWPl d5drsQGh/4GJw4wBy0AaIEZ4eqyHu84xLEwFvW6BvHV1kmvJ6CnnV/IkO/Nmx3jpiM0y 74UpmuVJ0DdNsT1iBomnl6Ce3IOz7WVnZhMP5SaVQTJ7L8Z+KNU08PbeihaEl40BjHlN pYjp24oFI0v7fk8elxvH/8LDd7R3Pe5OVfjESx4msWw/AJirZS7ka4X/Iix5RL2CuP5A 8h3w== 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=tgu9rCUlCUyRg9pTWOOFz0QLkS3psF0id2QKUuVnVNU=; b=QQn4oGO9HF+0cszUHU1fNHVT4SYgeniAR3jwMnkF7jnFBCzbnGzmgXfEXY5w50H6gu vOww8eff2EEapi800pvtoTbwLvkyQn+KhA8RIl0zZSKoi8Rp/SfiVbNXP+WTQM8GGXrw eeT6CFbZbq3BUMK1WO8q+DR/41W7W5/HwwyS2AarQMCEwZin4gup+ri2aoBNwj0S5XlJ vTPVQByh4Y8IVuEs1Tz9SRV0Hz7MO5Knls7VoHzgEo9mNOf6irb8Eqm72eG4P46EsDEv /WLC4vUAywf/Ok/KTIXNi5ro3ox0LMID9Jo3OG6I/70l3QKfV4efucN/P4HmS6HanpIz 7pLQ== X-Gm-Message-State: APjAAAWsjPT/7Ldu+ALpu+Vu5VYMvjV7EuTA+DFiiJJDh/NZ7vpTUG/w q1Z2Yfj4EQFErX5t21cVdPp23wEyWVFnZ5vsdqTJSA== X-Received: by 2002:a17:902:8a8b:: with SMTP id p11mr46550449plo.227.1554936756671; Wed, 10 Apr 2019 15:52:36 -0700 (PDT) MIME-Version: 1.0 References: <20190410220301.2332-1-louis@kragniz.eu> <20190410224124.6901-1-louis@kragniz.eu> In-Reply-To: <20190410224124.6901-1-louis@kragniz.eu> From: Nick Desaulniers Date: Wed, 10 Apr 2019 15:52:25 -0700 Message-ID: Subject: Re: [PATCH v2] afs: use correct format characters To: Louis Taylor Cc: David Howells , linux-afs@lists.infradead.org, LKML , clang-built-linux@googlegroups.com 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 Wed, Apr 10, 2019 at 3:41 PM Louis Taylor wrote: > > When compiling with -Wformat, clang warns: > > fs/afs/flock.c:632:29: warning: format specifies type 'short' but the argument has type > 'unsigned char' [-Wformat] > _leave(" = %d [%hd]", ret, fl->fl_type); > ~~~ ^~~~~~~~~~~ > > fs/afs/dir.c:138:11: warning: format specifies type 'unsigned short' but > the argument has type 'int' [-Wformat] > ntohs(dbuf->blocks[tmp].hdr.magic)); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > fl_type is declared as an unsigned char unconditionally in > include/linux/fs.h, so use the correct format characters. Thanks for the v2, probably should include a note about ntohs. That case in particular looks more complicated, due to the definition of ntohs (which uses __swab16). If you keep the previous flag of %04hx, but add an explicit cast to u16, does the warning go away? If so, that might be a better fix. - ntohs(dbuf->blocks[tmp].hdr.magic)); + (u16)ntohs(dbuf->blocks[tmp].hdr.magic)); ? Particularly, I'm curious about the return type of GNU C statement expressions, in the definition of __swab16 if __HAVE_BUILTIN_BSWAP16__ is not defined. > > Link: https://github.com/ClangBuiltLinux/linux/issues/378 > Signed-off-by: Louis Taylor > --- > fs/afs/dir.c | 2 +- > fs/afs/flock.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/afs/dir.c b/fs/afs/dir.c > index 8a2562e3a316..4ceaec94e9c5 100644 > --- a/fs/afs/dir.c > +++ b/fs/afs/dir.c > @@ -133,7 +133,7 @@ static bool afs_dir_check_page(struct afs_vnode *dvnode, struct page *page, > dbuf = kmap(page); > for (tmp = 0; tmp < qty; tmp++) { > if (dbuf->blocks[tmp].hdr.magic != AFS_DIR_MAGIC) { > - printk("kAFS: %s(%lx): bad magic %d/%d is %04hx\n", > + printk("kAFS: %s(%lx): bad magic %d/%d is %04x\n", > __func__, dvnode->vfs_inode.i_ino, tmp, qty, > ntohs(dbuf->blocks[tmp].hdr.magic)); > trace_afs_dir_check_failed(dvnode, off, i_size); > diff --git a/fs/afs/flock.c b/fs/afs/flock.c > index 6a0174258382..be4c3f6a3178 100644 > --- a/fs/afs/flock.c > +++ b/fs/afs/flock.c > @@ -629,7 +629,7 @@ static int afs_do_getlk(struct file *file, struct file_lock *fl) > > ret = 0; > error: > - _leave(" = %d [%hd]", ret, fl->fl_type); > + _leave(" = %d [%hhu]", ret, fl->fl_type); > return ret; > } - Thanks, ~Nick Desaulniers