On Mon, Jan 27, 2025 at 12:18 PM <[email protected]> wrote:
>
> Hi, Nadav
>
> The dominant style in the project seems to be char *v, not char* v.
>
> > +     passwd_argv[0] = (char *) "passwd";
> > +     passwd_argv[1] = (char *) "--";
> > +     passwd_argv[2] = (char *) login_name;
> > +     passwd_argv[3] = NULL;
>
> The type of a string literal is already char *, so the first two don't need
> the cast. You could even write it more compactly, like this:
>
>         char *passwd_argv[] = { "passwd", "--", (char *)login_name, NULL };
>

Technically, string literals are of type "const char *", not "char *".
And when you assign string literals to "char *" like that,
unpredictable behavior can happen when the strings get modified by
some other function.

Perhaps what you really intended is this?

const char *passwd_argv[] = { "passwd", "--", login_name, NULL };
_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to