Re: [PATCH v2 2/3] tools/nolibc: implement fd-based FILE streams

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

 



On Sun, Apr 02, 2023 at 01:02:46PM +0000, Thomas Weißschuh wrote:
> Willy:
> 
> This uses intptr_t instead of uintptr_t as proposed because uintptr_t
> can not be negative.

Ah yes good point.

> +/* provides the fd from of stream. */
> +static __attribute__((unused))
> +int fileno(FILE *stream)
> +{
> +	intptr_t i = (intptr_t)stream;
> +
> +	if (i > 0) {

If you don't mind I'll change this to "if (i >= 0)" since we also want
to set errno on NULL.


> +		SET_ERRNO(EBADF);
> +		return -1;
> +	}
> +	return ~i;
> +}

OK for the rest of the series.

Thanks!
Willy



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux