[BusyBox] nonsense in deallocvt.c and little fix in strings.c bb_unstable

Tito farmatito at tiscali.it
Fri Mar 21 13:39:04 UTC 2003


Hi,
I've downloaded latest CVS tar and while browsing through to sources I 
stumbled across
something that seems nonsense to me in deallocvt.c:

if (argc > 2)
     bb_show_usage();

and later on

for (i = 1; i < argc; i++) {
     num = atoi(argv[i]);
etc.

Why do we need a for loop here if we allow only one arg?
Couldn't we do something like this?

int deallocvt_main(int argc, char *argv[])
{
	int fd, num=0;

	if (argc > 2)
	bb_show_usage();

	fd = get_console_fd();

	/* deallocate all unused consoles  num=0 */
	if (argc == 1)
		goto disallocate_all;

	num=bb_xgetlarg(argv[1], 10, 0, INT_MAX);

	switch(num)
	{
		case 0:
			bb_error_msg("0: illegal VT number");
			break;
		case 1:
			bb_error_msg("VT 1 cannot be deallocated");
			break;
		default:
disallocate_all:
			if (ioctl(fd, VT_DISALLOCATE, num))
				bb_perror_msg_and_die("VT_DISALLOCATE");
			return EXIT_SUCCESS;
	}
	return EXIT_FAILURE;
}

BTW: there is a c++ style comment in the source gcc -Wall -pedantic is 
unhappy about.

In strings.c

n = bb_xgetlarg(optarg, 10, 1, LONG_MAX);

have to be changed in

n = bb_xgetlarg(optarg, 10, 1, INT_MAX);

due to the fact that we declare int n;

Ciao,
Tito




More information about the busybox mailing list