From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f178.google.com ([209.85.210.178]:33082 "EHLO mail-pf1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726943AbeJMAvb (ORCPT ); Fri, 12 Oct 2018 20:51:31 -0400 Received: by mail-pf1-f178.google.com with SMTP id 78-v6so4138080pfq.0 for ; Fri, 12 Oct 2018 10:18:02 -0700 (PDT) MIME-Version: 1.0 References: <1539274203.2623.56.camel@linux.vnet.ibm.com> <20181011203126.15338-1-ndesaulniers@google.com> <1539356751.2656.5.camel@linux.ibm.com> In-Reply-To: From: Nick Desaulniers Date: Fri, 12 Oct 2018 10:17:50 -0700 Message-ID: Subject: Re: [PATCH] KEYS: trusted: fix -Wvarags warning To: denkenz@gmail.com Cc: jejb@linux.ibm.com, dhowells@redhat.com, Nathan Chancellor , Eric Biggers , zohar@linux.vnet.ibm.com, jmorris@namei.org, serge@hallyn.com, linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-integrity-owner@vger.kernel.org List-ID: On Fri, Oct 12, 2018 at 10:05 AM Nick Desaulniers wrote: > > On Fri, Oct 12, 2018 at 8:14 AM Denis Kenzior wrote: > > > > Hi James, > > > > >> So can't we simply use 'bool' or uint32 as the type for h3 instead > > >> of re-ordering everything > > > > > > The problem is the standard is ambiguious. The only thing that's > > > guaranteed to work for all time is a char *. If you want to keep the > > > order, what I'd suggest is inserting a dummy pointer argument which is > > > always expected to be NULL between the h3 and the varargs. > > > > So maybe I'm misunderstanding something, but the issue seems to be that > > unsigned char is promoted to 'unsigned char *' by Clang and probably > > unsigned int or int by gcc. > > No. This is extremely well defined behavior in C. In C, integral > types are NEVER promoted to pointer to integer types, only to larger > integral types through rules more complicated than the correct flags > to pass to `tar`. > https://xkcd.com/1168/ And may have their signedness converted. https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules is the reference I use, though I always feel like there's quite a bit of mental gymnastics involved interpreting it. > > > > > So instead of having unsigned char h3, can't we simply have bool h3 or > > unsigned int h3? > > int is the default argument promotion. Proposed: > https://github.com/ClangBuiltLinux/linux/issues/41#issuecomment-428365339 > > > > > Regards, > > -Denis > > > > > -- > Thanks, > ~Nick Desaulniers -- Thanks, ~Nick Desaulniers