public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Christoph Hellwig <hch@lst.de>,
	Keith Busch <keith.busch@intel.com>,
	Sagi Grimberg <sagi@grimberg.me>,
	Johannes Thumshirn <jthumshirn@suse.de>,
	Hannes Reinecke <hare@suse.de>,
	linux-nvme@lists.infradead.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 2/3] string.h: add memcpy_and_pad()
Date: Tue, 05 Sep 2017 20:18:02 +0200	[thread overview]
Message-ID: <1504635482.4516.3.camel@suse.com> (raw)
In-Reply-To: <CAK8P3a0u5w1C+L6t9h5+4fu0gt79u68B+txhF6adAT3MVfwW3Q@mail.gmail.com>

On Tue, 2017-09-05 at 09:28 +0200, Arnd Bergmann wrote:
> 
> > +/**
> > + * memcpy_and_pad - Copy one buffer to another with padding
> > + * @dest: Where to copy to
> > + * @dest_len: The destination buffer size
> > + * @src: Where to copy from
> > + * @count: The number of bytes to copy
> > + * @pad: Character to use for padding if space is left in
> > destination.
> > + */
> > +__FORTIFY_INLINE void memcpy_and_pad(void *dest, size_t dest_len,
> > +                                    const void *src, size_t count,
> > int pad)
> > +{
> 
> This is causing compile-time warnings for me:
> 
> In file included from /git/arm-soc/arch/x86/include/asm/string.h:2:0,
>                  from /git/arm-soc/include/linux/string.h:18,
>                  from /git/arm-soc/arch/x86/include/asm/page_32.h:34,
>                  from /git/arm-soc/arch/x86/include/asm/page.h:13,
>                  from /git/arm-
> soc/arch/x86/include/asm/thread_info.h:11,
>                  from /git/arm-soc/include/linux/thread_info.h:37,
>                  from /git/arm-soc/arch/x86/include/asm/preempt.h:6,
>                  from /git/arm-soc/include/linux/preempt.h:80,
>                  from /git/arm-soc/include/linux/spinlock.h:50,
>                  from /git/arm-soc/include/linux/seqlock.h:35,
>                  from /git/arm-soc/include/linux/time.h:5,
>                  from /git/arm-soc/include/linux/stat.h:18,
>                  from /git/arm-soc/include/linux/module.h:10,
>                  from /git/arm-soc/drivers/md/dm-integrity.c:9:
> /git/arm-soc/arch/x86/include/asm/string_32.h:196:25: error:
> '__memcpy' is static but used in inline function 'memcpy_and_pad'
> which is not static [-Werror]
>  #define memcpy(t, f, n) __memcpy((t), (f), (n))
>                          ^~~~~~~~
> /git/arm-soc/include/linux/string.h:466:3: note: in expansion of
> macro 'memcpy'
> 
>    ^
> /git/arm-soc/arch/x86/include/asm/string_32.h:196:25: error:
> '__memcpy' is static but used in inline function 'memcpy_and_pad'
> which is not static [-Werror]
>  #define memcpy(t, f, n) __memcpy((t), (f), (n))
>                          ^~~~~~~~
> 
> The problem is the use of __FORTIFY_INLINE outside of the #ifdef
> section above it.
> I used an ugly local workaround, duplicating the function with a
> 'static inline' variant
> in an #else block. Alternatively we could add an extern version in
> lib/string.c for the
> non-fortified case.

I'm sorry. It seems that I messed the code up by trying to do it right.
I suggest to simply drop the fortification code from this function,
which is not a "common str/mem function" anyway. Please tell me if
that'd be ok for you.

I'll send a patch in a follow-up email. 

Martin

-- 
Dr. Martin Wilck <mwilck@suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

  reply	other threads:[~2017-09-05 18:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-20 16:33 [PATCH v3 0/3] Improve readbility of NVME "wwid" attribute Martin Wilck
2017-07-20 16:34 ` [PATCH v3 1/3] string.h: add memcpy_and_pad() Martin Wilck
2017-07-22  3:45   ` kbuild test robot
2017-07-23 18:18   ` kbuild test robot
2017-07-20 16:34 ` [PATCH v3 2/3] nvmet: identify controller: improve standard compliance Martin Wilck
2017-07-20 16:34 ` [PATCH v3 3/3] nvme: wwid_show: strip trailing 0-bytes Martin Wilck
2017-07-20 20:11   ` Keith Busch
2017-08-10  8:45   ` Christoph Hellwig
2017-08-14 20:12     ` [PATCH v4 0/3] Improve readbility of NVME "wwid" attribute (target side) Martin Wilck
2017-08-14 20:12       ` [PATCH v4 1/3] nvmet_execute_identify_ctrl: don't overwrite with 0-bytes Martin Wilck
2017-08-14 20:12       ` [PATCH v4 2/3] string.h: add memcpy_and_pad() Martin Wilck
2017-09-05  7:28         ` Arnd Bergmann
2017-09-05 18:18           ` Martin Wilck [this message]
2017-09-05 18:23           ` [PATCH] string.h: un-fortify memcpy_and_pad Martin Wilck
2017-09-05 19:26             ` Arnd Bergmann
2017-09-06 13:02               ` Arnd Bergmann
2017-08-14 20:12       ` [PATCH v4 3/3] nvmet_execute_identify_ctrl: use memcpy_and_pad() Martin Wilck
2017-08-15  9:10       ` [PATCH v4 0/3] Improve readbility of NVME "wwid" attribute (target side) Sagi Grimberg
2017-08-16  8:12       ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1504635482.4516.3.camel@suse.com \
    --to=mwilck@suse.com \
    --cc=arnd@arndb.de \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jthumshirn@suse.de \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox