<p dir="ltr">Hi<br>
Le 23 nov. 2015 08:19, "John Crispin" <<a href="mailto:blogic@openwrt.org">blogic@openwrt.org</a>> a écrit :<br>
><br>
> Hi,<br>
><br>
> subject relates to extern but then the patch adds const. please make the<br>
> description consistent with the content<br>
></p>
<p dir="ltr">The subject do start with "use const"<br>
I will improve it in v2</p>
<p dir="ltr">> John<br>
><br>
> On 23/11/2015 01:39, Etienne CHAMPETIER wrote:<br>
> > extern for function declaration in '.h' doesn't make sense<br>
> ><br>
> > Signed-off-by: Etienne CHAMPETIER <<a href="mailto:champetier.etienne@gmail.com">champetier.etienne@gmail.com</a>><br>
> > ---<br>
> > jail/elf.c | 28 +++++++++++++++-------------<br>
> > jail/elf.h | 10 +++++-----<br>
> > 2 files changed, 20 insertions(+), 18 deletions(-)<br>
> ><br>
> > diff --git a/jail/elf.c b/jail/elf.c<br>
> > index 34a5aca..a26aa0b 100644<br>
> > --- a/jail/elf.c<br>
> > +++ b/jail/elf.c<br>
> > @@ -69,7 +69,7 @@ static void alloc_library(const char *path, const char *name)<br>
> > DEBUG("adding library %s/%s\n", path, name);<br>
> > }<br>
> ><br>
> > -static int elf_open(char **dir, char *file)<br>
> > +static int elf_open(char **dir, const char *file)<br>
> > {<br>
> > struct library_path *p;<br>
> > char path[256];<br>
> > @@ -95,7 +95,7 @@ static int elf_open(char **dir, char *file)<br>
> > return fd;<br>
> > }<br>
> ><br>
> > -char* find_lib(char *file)<br>
> > +char* find_lib(const char *file)<br>
> > {<br>
> > struct library *l;<br>
> > static char path[256];<br>
> > @@ -114,7 +114,7 @@ char* find_lib(char *file)<br>
> > return path;<br>
> > }<br>
> ><br>
> > -static int elf64_find_section(char *map, unsigned int type, unsigned int *offset, unsigned int *size, unsigned int *vaddr)<br>
> > +static int elf64_find_section(const char *map, unsigned int type, unsigned int *offset, unsigned int *size, unsigned int *vaddr)<br>
> > {<br>
> > Elf64_Ehdr *e;<br>
> > Elf64_Phdr *ph;<br>
> > @@ -137,7 +137,7 @@ static int elf64_find_section(char *map, unsigned int type, unsigned int *offset<br>
> > return -1;<br>
> > }<br>
> ><br>
> > -static int elf32_find_section(char *map, unsigned int type, unsigned int *offset, unsigned int *size, unsigned int *vaddr)<br>
> > +static int elf32_find_section(const char *map, unsigned int type, unsigned int *offset, unsigned int *size, unsigned int *vaddr)<br>
> > {<br>
> > Elf32_Ehdr *e;<br>
> > Elf32_Phdr *ph;<br>
> > @@ -160,7 +160,7 @@ static int elf32_find_section(char *map, unsigned int type, unsigned int *offset<br>
> > return -1;<br>
> > }<br>
> ><br>
> > -static int elf_find_section(char *map, unsigned int type, unsigned int *offset, unsigned int *size, unsigned int *vaddr)<br>
> > +static int elf_find_section(const char *map, unsigned int type, unsigned int *offset, unsigned int *size, unsigned int *vaddr)<br>
> > {<br>
> > int clazz = map[EI_CLASS];<br>
> ><br>
> > @@ -174,10 +174,10 @@ static int elf_find_section(char *map, unsigned int type, unsigned int *offset,<br>
> > return -1;<br>
> > }<br>
> ><br>
> > -static int elf32_scan_dynamic(char *map, int dyn_offset, int dyn_size, int load_offset)<br>
> > +static int elf32_scan_dynamic(const char *map, int dyn_offset, int dyn_size, int load_offset)<br>
> > {<br>
> > Elf32_Dyn *dynamic = (Elf32_Dyn *) (map + dyn_offset);<br>
> > - char *strtab = NULL;<br>
> > + const char *strtab = NULL;<br>
> ><br>
> > while ((void *) dynamic < (void *) (map + dyn_offset + dyn_size)) {<br>
> > Elf32_Dyn *curr = dynamic;<br>
> > @@ -208,10 +208,10 @@ static int elf32_scan_dynamic(char *map, int dyn_offset, int dyn_size, int load_<br>
> > return 0;<br>
> > }<br>
> ><br>
> > -static int elf64_scan_dynamic(char *map, int dyn_offset, int dyn_size, int load_offset)<br>
> > +static int elf64_scan_dynamic(const char *map, int dyn_offset, int dyn_size, int load_offset)<br>
> > {<br>
> > Elf64_Dyn *dynamic = (Elf64_Dyn *) (map + dyn_offset);<br>
> > - char *strtab = NULL;<br>
> > + const char *strtab = NULL;<br>
> ><br>
> > while ((void *) dynamic < (void *) (map + dyn_offset + dyn_size)) {<br>
> > Elf64_Dyn *curr = dynamic;<br>
> > @@ -242,7 +242,7 @@ static int elf64_scan_dynamic(char *map, int dyn_offset, int dyn_size, int load_<br>
> > return 0;<br>
> > }<br>
> ><br>
> > -int elf_load_deps(char *library)<br>
> > +int elf_load_deps(const char *library)<br>
> > {<br>
> > unsigned int dyn_offset, dyn_size;<br>
> > unsigned int load_offset, load_vaddr;<br>
> > @@ -288,10 +288,12 @@ int elf_load_deps(char *library)<br>
> > if (dir) {<br>
> > alloc_library(dir, library);<br>
> > } else {<br>
> > - char *elf = strdup(library);<br>
> > + char *elf1 = strdup(library);<br>
> > + char *elf2 = strdup(library);<br>
> ><br>
> > - alloc_library(dirname(elf), basename(library));<br>
> > - free(elf);<br>
> > + alloc_library(dirname(elf1), basename(elf2));<br>
> > + free(elf1);<br>
> > + free(elf2);<br>
> > }<br>
> > clazz = map[EI_CLASS];<br>
> ><br>
> > diff --git a/jail/elf.h b/jail/elf.h<br>
> > index 3ae311e..6c14c39 100644<br>
> > --- a/jail/elf.h<br>
> > +++ b/jail/elf.h<br>
> > @@ -28,11 +28,11 @@ struct library_path {<br>
> > char *path;<br>
> > };<br>
> ><br>
> > -extern struct avl_tree libraries;<br>
> > +struct avl_tree libraries;<br>
> ><br>
> > -extern void alloc_library_path(const char *path);<br>
> > -extern char* find_lib(char *file);<br>
> > -extern int elf_load_deps(char *library);<br>
> > -extern void load_ldso_conf(const char *conf);<br>
> > +void alloc_library_path(const char *path);<br>
> > +int elf_load_deps(const char *library);<br>
> > +char* find_lib(const char *file);<br>
> > +void load_ldso_conf(const char *conf);<br>
> ><br>
> > #endif<br>
> ><br>
</p>