Re: [PATCH] config: avoid "write_in_full(fd, buf, len) != len" pattern

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Nov 18, 2017 at 11:20:04AM +0100, René Scharfe wrote:

> Am 17.11.2017 um 23:06 schrieb Jeff King:
> > There's one more case in write_section() that uses "==". That's not
> > actually wrong, but I wonder if we'd want to make it "< 0" for
> > consistency.
> 
> Actually it *is* wrong.

Thanks for digging, I didn't look beyond that single line.

> -- >8 --
> Subject: [PATCH] config: flip return value of write_section()
> 
> d9bd4cbb9cc (config: flip return value of store_write_*()) made
> write_section() follow the convention of write(2) to return -1 on error
> and the number of written bytes on success.  3b48045c6c7 (Merge branch
> 'sd/branch-copy') changed it back to returning 0 on error and 1 on
> success, but left its callers still checking for negative values.
> 
> Let write_section() follow the convention of write(2) again to meet the
> expectations of its callers.

Yikes. It looks like this slipped by on the tests because we always
check "< 0" in the callers, not non-zero. So success would not look like
failure, but failure would look like success. And write failure does not
happen regularly in the test suite.

So this looks correct, and well-explained.

> Reported-by: Jeff King <peff@xxxxxxxx>
> Signed-off-by: Rene Scharfe <l.s.r@xxxxxx>

I'm not sure I deserve a reported-by if I say "it looks fine" but am
totally wrong. ;)

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux