Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1356487

Re: [PATCH v14] x86, mce: Add memcpy_mcsafe()

From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v14] x86, mce: Add memcpy_mcsafe()
Date 2016-03-12 18:20 +0100
Message-ID <rbVmN-Zf-11@gated-at.bofh.it> (permalink)
References <r6cTo-2cE-13@gated-at.bofh.it> <rberv-312-3@gated-at.bofh.it> <rbeBb-34j-5@gated-at.bofh.it> <rbDzA-4vT-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* Tony Luck <tony.luck@gmail.com> wrote:

> On Thu, Mar 10, 2016 at 11:37 AM, Luck, Tony <tony.luck@intel.com> wrote:
> >> But you return 0 == false for success and 1 == true for failure.
> >
> > Aaargh!  -ETOOMUCHSHELLSCRIPTPROGRAMMING
> >
> > -Tony
> 
> Options to fix this:
> 1) Just change the comments in the code.
>      This seems like it would confuse people as I thing most people
>      would expect the "true" return to mean the copy succeeded.
> 2) Reverse the return values.
>      Better that option 1 - but doesn't leave scope to return a count
>      if some future user does want to know where the copy failed.
> 3) Change the return type back from "bool" to "int"
>      0 == success, non-zero == fail (with option to put the non-copied
> byte count in later).
> 4) Something else

Please use the copy_*_user() memory copying API semantics, which are: return 
negative code (-EFAULT) on error, 0 on success.

Don't return 1 and please don't use bools for any memory copy library 
functionality.

Thanks,

	Ingo

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v14] x86, mce: Add memcpy_mcsafe() Mika Penttilä <mika.penttila@nextfour.com> - 2016-03-10 20:30 +0100
  RE: [PATCH v14] x86, mce: Add memcpy_mcsafe() "Luck, Tony" <tony.luck@intel.com> - 2016-03-10 20:40 +0100
    Re: [PATCH v14] x86, mce: Add memcpy_mcsafe() Tony Luck <tony.luck@gmail.com> - 2016-03-11 23:20 +0100
      Re: [PATCH v14] x86, mce: Add memcpy_mcsafe() Dan Williams <dan.j.williams@intel.com> - 2016-03-11 23:20 +0100
      Re: [PATCH v14] x86, mce: Add memcpy_mcsafe() Ingo Molnar <mingo@kernel.org> - 2016-03-12 18:20 +0100
        Re: [PATCH v14] x86, mce: Add memcpy_mcsafe() Linus Torvalds <torvalds@linux-foundation.org> - 2016-03-13 02:20 +0100
          Re: [PATCH v14] x86, mce: Add memcpy_mcsafe() Ingo Molnar <mingo@kernel.org> - 2016-03-13 10:30 +0100
            [PATCH] x86/mm, x86/mce: Fix return type/value for memcpy_mcsafe() Tony Luck <tony.luck@intel.com> - 2016-03-14 23:40 +0100
              [tip:x86/urgent] x86/mm, x86/mce: Fix return type/value for  memcpy_mcsafe() tip-bot for Tony Luck <tipbot@zytor.com> - 2016-03-16 09:40 +0100

csiph-web