[OpenWrt-Devel] [PATCH procd 3/4] ujail: use const, stop using extern

Etienne Champetier champetier.etienne at gmail.com
Mon Nov 23 03:09:53 EST 2015


Hi
Le 23 nov. 2015 08:19, "John Crispin" <blogic at openwrt.org> a écrit :
>
> Hi,
>
> subject relates to extern but then the patch adds const. please make the
> description consistent with the content
>

The subject do start with "use const"
I will improve it in v2

>         John
>
> On 23/11/2015 01:39, Etienne CHAMPETIER wrote:
> > extern for function declaration in '.h' doesn't make sense
> >
> > Signed-off-by: Etienne CHAMPETIER <champetier.etienne at gmail.com>
> > ---
> >  jail/elf.c | 28 +++++++++++++++-------------
> >  jail/elf.h | 10 +++++-----
> >  2 files changed, 20 insertions(+), 18 deletions(-)
> >
> > diff --git a/jail/elf.c b/jail/elf.c
> > index 34a5aca..a26aa0b 100644
> > --- a/jail/elf.c
> > +++ b/jail/elf.c
> > @@ -69,7 +69,7 @@ static void alloc_library(const char *path, const
char *name)
> >       DEBUG("adding library %s/%s\n", path, name);
> >  }
> >
> > -static int elf_open(char **dir, char *file)
> > +static int elf_open(char **dir, const char *file)
> >  {
> >       struct library_path *p;
> >       char path[256];
> > @@ -95,7 +95,7 @@ static int elf_open(char **dir, char *file)
> >       return fd;
> >  }
> >
> > -char* find_lib(char *file)
> > +char* find_lib(const char *file)
> >  {
> >       struct library *l;
> >       static char path[256];
> > @@ -114,7 +114,7 @@ char* find_lib(char *file)
> >       return path;
> >  }
> >
> > -static int elf64_find_section(char *map, unsigned int type, unsigned
int *offset, unsigned int *size, unsigned int *vaddr)
> > +static int elf64_find_section(const char *map, unsigned int type,
unsigned int *offset, unsigned int *size, unsigned int *vaddr)
> >  {
> >       Elf64_Ehdr *e;
> >       Elf64_Phdr *ph;
> > @@ -137,7 +137,7 @@ static int elf64_find_section(char *map, unsigned
int type, unsigned int *offset
> >       return -1;
> >  }
> >
> > -static int elf32_find_section(char *map, unsigned int type, unsigned
int *offset, unsigned int *size, unsigned int *vaddr)
> > +static int elf32_find_section(const char *map, unsigned int type,
unsigned int *offset, unsigned int *size, unsigned int *vaddr)
> >  {
> >       Elf32_Ehdr *e;
> >       Elf32_Phdr *ph;
> > @@ -160,7 +160,7 @@ static int elf32_find_section(char *map, unsigned
int type, unsigned int *offset
> >       return -1;
> >  }
> >
> > -static int elf_find_section(char *map, unsigned int type, unsigned int
*offset, unsigned int *size, unsigned int *vaddr)
> > +static int elf_find_section(const char *map, unsigned int type,
unsigned int *offset, unsigned int *size, unsigned int *vaddr)
> >  {
> >       int clazz = map[EI_CLASS];
> >
> > @@ -174,10 +174,10 @@ static int elf_find_section(char *map, unsigned
int type, unsigned int *offset,
> >       return -1;
> >  }
> >
> > -static int elf32_scan_dynamic(char *map, int dyn_offset, int dyn_size,
int load_offset)
> > +static int elf32_scan_dynamic(const char *map, int dyn_offset, int
dyn_size, int load_offset)
> >  {
> >       Elf32_Dyn *dynamic = (Elf32_Dyn *) (map + dyn_offset);
> > -     char *strtab = NULL;
> > +     const char *strtab = NULL;
> >
> >       while ((void *) dynamic < (void *) (map + dyn_offset + dyn_size))
{
> >               Elf32_Dyn *curr = dynamic;
> > @@ -208,10 +208,10 @@ static int elf32_scan_dynamic(char *map, int
dyn_offset, int dyn_size, int load_
> >       return 0;
> >  }
> >
> > -static int elf64_scan_dynamic(char *map, int dyn_offset, int dyn_size,
int load_offset)
> > +static int elf64_scan_dynamic(const char *map, int dyn_offset, int
dyn_size, int load_offset)
> >  {
> >       Elf64_Dyn *dynamic = (Elf64_Dyn *) (map + dyn_offset);
> > -     char *strtab = NULL;
> > +     const char *strtab = NULL;
> >
> >       while ((void *) dynamic < (void *) (map + dyn_offset + dyn_size))
{
> >               Elf64_Dyn *curr = dynamic;
> > @@ -242,7 +242,7 @@ static int elf64_scan_dynamic(char *map, int
dyn_offset, int dyn_size, int load_
> >       return 0;
> >  }
> >
> > -int elf_load_deps(char *library)
> > +int elf_load_deps(const char *library)
> >  {
> >       unsigned int dyn_offset, dyn_size;
> >       unsigned int load_offset, load_vaddr;
> > @@ -288,10 +288,12 @@ int elf_load_deps(char *library)
> >       if (dir) {
> >               alloc_library(dir, library);
> >       } else {
> > -             char *elf = strdup(library);
> > +             char *elf1 = strdup(library);
> > +             char *elf2 = strdup(library);
> >
> > -             alloc_library(dirname(elf), basename(library));
> > -             free(elf);
> > +             alloc_library(dirname(elf1), basename(elf2));
> > +             free(elf1);
> > +             free(elf2);
> >       }
> >       clazz = map[EI_CLASS];
> >
> > diff --git a/jail/elf.h b/jail/elf.h
> > index 3ae311e..6c14c39 100644
> > --- a/jail/elf.h
> > +++ b/jail/elf.h
> > @@ -28,11 +28,11 @@ struct library_path {
> >       char *path;
> >  };
> >
> > -extern struct avl_tree libraries;
> > +struct avl_tree libraries;
> >
> > -extern void alloc_library_path(const char *path);
> > -extern char* find_lib(char *file);
> > -extern int elf_load_deps(char *library);
> > -extern void load_ldso_conf(const char *conf);
> > +void alloc_library_path(const char *path);
> > +int elf_load_deps(const char *library);
> > +char* find_lib(const char *file);
> > +void load_ldso_conf(const char *conf);
> >
> >  #endif
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20151123/6c31c19f/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list