[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    RE: Print full username and groupname for ls command
From:       David Laight <David.Laight () ACULAB ! COM>
Date:       2024-02-25 14:14:17
Message-ID: 4be2274336d44ba2913aec43c9e5279a () AcuMS ! aculab ! com
[Download RAW message or body]

From: Denys Vlasenko
> Sent: 25 February 2024 00:06
> 
> I think we can simply stop the truncation, like this:
> 
> -                               column += printf("%-8.8s %-8.8s ",
> +                               column += printf("%-8s %-8s ",
> 
> without additional loop to measure max length.

That code isn't safe with a standard libc.
If printf() actually does a write() for any reason and the write
fails then printf() returns -1 not the length.

If you want to check for error (eg disk full) then checking the
return value of printf() is also fairly pointless.
You really need to call fflush() and then ferror().

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic