Re: [PATCH v14] x86, mce: Add memcpy_mcsafe()
From: Dan Williams
Date: Fri Mar 11 2016 - 17:14:51 EST
On Fri, Mar 11, 2016 at 2:10 PM, Tony Luck <tony.luck@xxxxxxxxx> wrote:
> On Thu, Mar 10, 2016 at 11:37 AM, Luck, Tony <tony.luck@xxxxxxxxx> wrote:
>>> But you return 0 == false for success and 1 == true for failure.
>> Aaargh! -ETOOMUCHSHELLSCRIPTPROGRAMMING
> 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
You could return 0 for success and -EIO for failure (positive value
for 'location' if that support ever resurfaces).
That would at least let me drop the ternary conversion I have in
memcpy_from_pmem()  to convert bool to an error code.