Re: [PATCH][next] mips: sgi-ip22: Replace "s[n]?printf" with sysfs_emit in sysfs callbacks

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

 



On Tue, Oct 15, 2024 at 03:01:13AM +0100, Maciej W. Rozycki wrote:
> On Tue, 15 Oct 2024, Paulo Miguel Almeida wrote:
> 
> > snprintf() has the documented, but still rather strange trait of
> > returning the length of the data that *would have been* written to the
> > array if space were available, rather than the arguably more useful
> > length of data *actually* written, [...]
> 
>  Why do you think that just returning `n - 1' in the case of a length 
> overflow would be more useful than returning the unmet buffer length 
> requirement?  I think the opposite is the case: the value returned lets 
> you reallocate the buffer for more space and retry, and there's no other 
> way to figure out how much this would be.  And if you need to know how 
> many characters were actually written, then `min(n - 1, snprintf(...))' 
> will do (and code you propose to replace does exactly that, open-coded).
> 
>  The change itself makes sense to me, but not your proposed description 
> I'm afraid.  Just replacing open-coded pieces with calls to `sysfs_emit' 
> is enough justification.
> 
>   Maciej

Thanks for taking the time to review this patch.

Will submit a v2 with the description you pointed out.

- Paulo A.




[Index of Archives]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux