Re: [RFC PATCH v9 01/11] trace-cmd: Make ports unsigned int

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

 



On Wed, 2019-04-03 at 09:00 -0400, Steven Rostedt wrote:
> On Tue,  2 Apr 2019 16:45:30 +0300
> Slavomir Kaslev <kaslevs@xxxxxxxxxx> wrote:
> 
> > -static int write_ints(char *buf, size_t buf_len, int *arr, int
> > arr_len)
> > +static unsigned int atou(const char *s)
> > +{
> > +	long r;
> > +
> > +	r = atol(s);
> > +	if (r >= 0 && r <= UINT_MAX)
> > +		return r;
> > +
> > +	return 0;
> > +}
> > +
> 
> I wonder if we should do this instead:
> 
> /* test a to u */
> static int tatou(const char *s, int *res)
> {
> 	long r;
> 
> 	r = atol(s);
> 	if (r >= 0 && r <= UINT_MAX) {
> 		*res = (unsigned)r;
> 		return 0;
> 	}
> 	return -1;
> }

Makes sense. I did consider it while writing this but decided to go
with the traditional "broken" prototype for such functions.




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux