Hi Tito !

>So I would simplify the code like:
>
>       opt_complementary = "-1:?2:SD:u+";
>       opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir,
>       &pw.pw_gecos, &pw.pw_shell, &usegroup, &pw.pw_uid);

IMO you miss one fact. The field pw.pw_uid (especially) is
different size and type on different systems/libraries
(sometimes only 16 bit data type). I think getopt32 expects
pointer to an integer or unsigned data type. Writing to 16 bit
data type using a pointer to int would write to unknown location.

Better to use a local variable, and let the compiler do the type
mangling:

  unsigned uid;
  ... getopt32( ..., &uid);
  pw.pw_uid = uid;

But nevertheless you are right, the code parts shall be merged.

--
Harald
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to