busybox-1.3.0 and nonstd APIs, installment 2

Denis Vlasenko vda.linux at googlemail.com
Mon Dec 18 21:26:54 UTC 2006


On Monday 18 December 2006 07:09, sampo at symlabs.com wrote:
> coreutils/stty.c 
> 
> cfgetispeed() is not declared as taking const argument in dietlibc.
> In glibc its declared with __const, whatever that means. Manual page
> does not show const. Perhaps dietlibc should declare with const?
> Or perhaps its not safe to make any assumptions about constness.
> Following casts silence the problem (which is a warning that
> halts compilation). 
> 
> diff -rub orig/busybox-1.3.0/coreutils/stty.c busybox-1.3.0/coreutils/stty.c
>  --- orig/busybox-1.3.0/coreutils/stty.c	2006-12-12 19:09:54.000000000 -0500
> +++ busybox-1.3.0/coreutils/stty.c	2006-12-17 15:21:47.000000000 -0500
> @@ -1224,8 +1224,8 @@
> 	const char *fmt_str = "%lu %lu\n\0ispeed %lu baud; ospeed %lu baud;";
> 	unsigned long ispeed, ospeed; 
> 
>  -	ospeed = ispeed = cfgetispeed(mode);
>  -	if (ispeed == 0 || ispeed == (ospeed = cfgetospeed(mode))) {
> +	ospeed = ispeed = cfgetispeed((struct termios*)mode);
> +	if (ispeed == 0 || ispeed == (ospeed = cfgetospeed((struct 
> termios*)mode))) {
> 		ispeed = ospeed;                /* in case ispeed was 0 */
> 	                 //0123 4 5 6 7 8 9
> 		fmt_str = "%lu\n\0\0\0\0\0speed %lu baud;"; 

"cfgetospeed() returns the output baud rate stored in the termios structure
pointed to by termios_p." Obviously, it does not modify the structure
and logically it should take const ptr. My manpage says
"speed_t cfgetospeed(const struct termios *termios_p);"

Should be fixed on dietlibc side.
--
vda



More information about the busybox mailing list