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

List:       busybox
Subject:    Re: typo in id.c?
From:       Tito <farmatito () tiscali ! it>
Date:       2011-01-26 19:53:50
Message-ID: 201101262053.50200.farmatito () tiscali ! it
[Download RAW message or body]

On Wednesday 26 January 2011 17:45:26 you wrote:
> Selon Tito <farmatito@tiscali.it>:
> 
> > On Wednesday 26 January 2011 15:24:17 Gilles Espinasse wrote:
> > > Selon Tito <farmatito@tiscali.it>:
> > > 
> > > > Hi,
> > > > in id.c maybe I've found a minor bug.
> > > > 
> > > > 		} else if (n < 0) { /* error in get_groups() */
> > > > -			if (!ENABLE_DESKTOP)
> > > > +			if (ENABLE_DESKTOP)
> > > > 				bb_error_msg_and_die("can't get groups");
> > > > 			else
> > > > 				return EXIT_FAILURE;
> > > > 		}
> > > > 
> > > > 
> > > > ciao,
> > > > Tito
> > > 
> > > 
> > > Another issue.
> > > 
> > > Should really 'return EXIT_FAILURE' depend of ENABLE_DESKTOP?
> > > 
> > > 
> > > Gilles
> > > 
> > 
> > My idea was ENABLE_DESKTOP = bloat so verbose error message
> > !ENABLE_DESKTOP= minimal so only return error to shell
> > 
> > Maybe I'm overlooking something obvious?
> > Ciao,
> > Tito
> > 
> > 
> I miss the _and_die part and think that was bad to have an exit status depending
> of ENABLE_DESKTOP.
> 
> I don't know if size would be better or worse without the else but exit status
> should remain inchanged.
> 
> A few lines above in print_common function, there is
> 			if (option_mask32) {
> 				if (ENABLE_DESKTOP)
> 					bb_error_msg("unknown ID %u", id);
> 				return EXIT_FAILURE;
> 			}
> which is a different way (no else, no _and_die) to have a similar handling (but
> there in a function)
> 
> 
> Gilles
Hi,
the older code was done with compiler dead code optimization in mind
and should in fact give more or less the same code as above in the end:

 
	if (ENABLE_DESKTOP)
		bb_error_msg_and_die("can't get groups");
	else
		return EXIT_FAILURE;

as in  

	if (0)                                                                       <=
		bb_error_msg_and_die("can't get groups");   <=  this is dead code 
	else                                                                        <=
		return EXIT_FAILURE;

or in

	if (1)                                                                      <=
		bb_error_msg_and_die("can't get groups");
	else                                                                       <=  this \
is dead code  and  bb_error_msg_and_die returns EXIT_FAILURE  return EXIT_FAILURE;    \
<= 



Ciao,
Tito
_______________________________________________
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