On 27/06/2017 06:44, Thomas Huth wrote: > Instead of declaring the prototypes for these functions in various > C files, introduce a proper header for them. This change also > revealed that the prototypes of setup_args_progname() did not match > the implementation - the argument can be a "const char *", so change > the code in argv.c accordingly. > > Signed-off-by: Thomas Huth <thuth@xxxxxxxxxx> > --- > lib/argv.c | 16 +++++++--------- > lib/argv.h | 10 ++++++++++ > lib/arm/setup.c | 3 +-- > lib/powerpc/setup.c | 3 +-- > lib/s390x/io.c | 2 +- > 5 files changed, 20 insertions(+), 14 deletions(-) > create mode 100644 lib/argv.h > > diff --git a/lib/argv.c b/lib/argv.c > index f2466d4..f0e183a 100644 > --- a/lib/argv.c > +++ b/lib/argv.c > @@ -6,10 +6,11 @@ > */ > > #include "libcflat.h" > +#include "argv.h" > #include "auxinfo.h" > > int __argc; > -char *__args; > +const char *__args; > char *__argv[100]; > char *__environ[200]; > > @@ -22,7 +23,7 @@ static char *copy_ptr = args_copy; > #define isalpha(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z') || (c) == '_') > #define isalnum(c) (isalpha(c) || ((c) >= '0' && (c) <= '9')) > > -static char *skip_blanks(char *p) > +static const char *skip_blanks(const char *p) > { > while (isblank(*p)) > ++p; > @@ -31,7 +32,7 @@ static char *skip_blanks(char *p) > > void __setup_args(void) > { > - char *args = __args; > + const char *args = __args; > char **argv = __argv + __argc; > > while (*(args = skip_blanks(args)) != '\0') { > @@ -43,7 +44,7 @@ void __setup_args(void) > __argc = argv - __argv; > } > > -void setup_args(char *args) > +static void setup_args(const char *args) > { > if (!args) > return; > @@ -52,16 +53,13 @@ void setup_args(char *args) > __setup_args(); > } > > -void setup_args_progname(char *args) > +void setup_args_progname(const char *args) > { > __argv[0] = copy_ptr; > strcpy(__argv[0], auxinfo.progname); > copy_ptr += strlen(auxinfo.progname) + 1; > ++__argc; > - if (args) { > - __args = args; > - __setup_args(); > - } > + setup_args(args); > } > > static char *env_eol(char *env) > diff --git a/lib/argv.h b/lib/argv.h > new file mode 100644 > index 0000000..2104dd4 > --- /dev/null > +++ b/lib/argv.h > @@ -0,0 +1,10 @@ > +/* > + * Set up arguments for main() and prepare environment variables > + * > + * This code is free software; you can redistribute it and/or modify it > + * under the terms of the GNU Library General Public License version 2. > + */ > + > +extern void __setup_args(void); > +extern void setup_args_progname(const char *args); > +extern void setup_env(char *env, int size); > diff --git a/lib/arm/setup.c b/lib/arm/setup.c > index 9974b4c..a0b1795 100644 > --- a/lib/arm/setup.c > +++ b/lib/arm/setup.c > @@ -14,6 +14,7 @@ > #include <libfdt/libfdt.h> > #include <devicetree.h> > #include <alloc.h> > +#include <argv.h> > #include <asm/thread_info.h> > #include <asm/setup.h> > #include <asm/page.h> > @@ -22,8 +23,6 @@ > > extern unsigned long stacktop; > extern void io_init(void); > -extern void setup_args_progname(const char *args); > -extern void setup_env(char *env, int size); > > char *initrd; > u32 initrd_size; > diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c > index f6cacdc..20a1e37 100644 > --- a/lib/powerpc/setup.c > +++ b/lib/powerpc/setup.c > @@ -14,14 +14,13 @@ > #include <libfdt/libfdt.h> > #include <devicetree.h> > #include <alloc.h> > +#include <argv.h> > #include <asm/setup.h> > #include <asm/page.h> > #include <asm/hcall.h> > > extern unsigned long stacktop; > extern void io_init(void); > -extern void setup_args_progname(const char *args); > -extern void setup_env(char *env, int size); > > char *initrd; > u32 initrd_size; > diff --git a/lib/s390x/io.c b/lib/s390x/io.c > index 067ecf7..4ab5bd9 100644 > --- a/lib/s390x/io.c > +++ b/lib/s390x/io.c > @@ -11,10 +11,10 @@ > * under the terms of the GNU Library General Public License version 2. > */ > #include <libcflat.h> > +#include <argv.h> > #include <asm/spinlock.h> > #include "sclp.h" > > -extern void setup_args_progname(const char *args); > extern char ipl_args[]; > > static struct spinlock lock; > Applied, thanks. Paolo