Skip to contentSkip to conversation

bsd-user: Fix some code style problems

PATCH In review shiliyang 2 participants 9 messages Jan 18, 2021 – Jan 21, 2021

lore
Share & tools
lore

shiliyang

author
#0 lore raw

v4 cover bsd-user: Fix some code style problems

This patch series fixes error style problems found by checkpatch.pl.

V3->V4:
Fix code style problems with branch bsd-user-rebase-3.1.

V2->V3:
Make the patch into a series.

V1->V2:
Add cover letter message.
Fix some style error in patch file before.

Liyang Shi (4):
bsd-user: "foo * bar" should be "foo *bar"
bsd-user: suspect code indent for conditional statements
bsd-user: do not use C99 // comments
bsd-user: space required after semicolon

 bsd-user/bsdload.c |  4 ++--
 bsd-user/elfload.c | 32 ++++++++++++++++----------------
 bsd-user/mmap.c    | 25 +++++++++++++------------
 3 files changed, 31 insertions(+), 30 deletions(-)
Signature · 1 line
2.29.1.59.gf9b6481aed
author
#1 lore raw

PATCH v4 1/4 bsd-user: "foo * bar" should be "foo *bar"

This patch fixes error style problems found by checkpatch.pl:
ERROR: "foo ** bar" should be "foo **bar".
ERROR: "foo * bar" should be "foo *bar"

---
 bsd-user/bsdload.c |  4 ++--
 bsd-user/elfload.c | 16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)
bsd-user/bsdload.c +2 -2
index d708a54b03..65a2346bc7 100644
@@ -36,7 +36,7 @@ abi_long memcpy_to_target(abi_ulong dest, const void *src,
     return 0;
 }
 
-static int count(char ** vec)
+static int count(char **vec)
 {
     int         i;
 
@@ -188,7 +188,7 @@ static int find_in_path(char *path, const char *filename, char *retpath,
     return found;
 }
 
-int loader_exec(const char * filename, char ** argv, char ** envp,
+int loader_exec(const char *filename, char **argv, char **envp,
              struct target_pt_regs *regs, struct image_info *infop,
              struct bsd_binprm *bprm)
 {
bsd-user/elfload.c +8 -8
index 373292e468..4d1a572534 100644
@@ -66,12 +66,12 @@ static int load_elf_sections(const struct elfhdr *hdr, struct elf_phdr *phdr,
 abi_ulong target_stksiz;
 abi_ulong target_stkbas;
 
-static inline void memcpy_fromfs(void * to, const void * from, unsigned long n)
+static inline void memcpy_fromfs(void *to, const void *from, unsigned long n)
 {
     memcpy(to, from, n);
 }
 
-static int load_aout_interp(void * exptr, int interp_fd);
+static int load_aout_interp(void *exptr, int interp_fd);
 
 #ifdef BSWAP_NEEDED
 static void bswap_ehdr(struct elfhdr *ehdr)
@@ -156,7 +156,7 @@ static void bswap_note(struct elf_note *en) { }
  * to be put directly into the top of new user memory.
  *
  */
-static abi_ulong copy_elf_strings(int argc,char ** argv, void **page,
+static abi_ulong copy_elf_strings(int argc, char **argv, void **page,
                                   abi_ulong p)
 {
     char *tmp, *tmp1, *pag = NULL;
@@ -288,7 +288,7 @@ static void padzero(abi_ulong elf_bss, abi_ulong last_bss)
     }
 }
 
-static abi_ulong load_elf_interp(struct elfhdr * interp_elf_ex,
+static abi_ulong load_elf_interp(struct elfhdr *interp_elf_ex,
         int interpreter_fd, abi_ulong *interp_load_addr)
 {
     struct elf_phdr *elf_phdata  =  NULL;
@@ -614,11 +614,11 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
     unsigned int interpreter_type = INTERPRETER_NONE;
     unsigned char ibcs2_interpreter;
     int i;
-    struct elf_phdr * elf_ppnt;
+    struct elf_phdr *elf_ppnt;
     struct elf_phdr *elf_phdata;
     abi_ulong elf_bss, elf_brk;
     int error, retval;
-    char * elf_interpreter;
+    char *elf_interpreter;
     abi_ulong baddr, elf_entry, et_dyn_addr, interp_load_addr = 0;
     abi_ulong reloc_func_desc = 0;
     char passed_fileno[6];
@@ -785,7 +785,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
        and then start this sucker up */
 
     {
-        char * passed_p;
+        char *passed_p;
 
         if (interpreter_type == INTERPRETER_AOUT) {
             snprintf(passed_fileno, sizeof(passed_fileno), "%d", bprm->fd);
@@ -2254,7 +2254,7 @@ out:
 
 #endif /* USE_ELF_CORE_DUMP */
 
-static int load_aout_interp(void * exptr, int interp_fd)
+static int load_aout_interp(void *exptr, int interp_fd)
 {
 
     printf("a.out interpreter not yet supported\n");
Signature · 1 line
2.29.1.59.gf9b6481aed
author
#2 lore raw

PATCH v4 2/4 bsd-user: suspect code indent for conditional statements

In reply to shiliyang

This patch fixes error style problems found by checkpatch.pl:
ERROR: suspect code indent for conditional statements

---
 bsd-user/elfload.c |  2 +-
 bsd-user/mmap.c    | 25 +++++++++++++------------
 2 files changed, 14 insertions(+), 13 deletions(-)
bsd-user/elfload.c +1 -1
index 4d1a572534..d5cab25607 100644
@@ -765,7 +765,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
         /* Now figure out which format our binary is */
         if ((N_MAGIC(interp_ex) != OMAGIC) && (N_MAGIC(interp_ex) != ZMAGIC) &&
                 (N_MAGIC(interp_ex) != QMAGIC)) {
-          interpreter_type = INTERPRETER_ELF;
+            interpreter_type = INTERPRETER_ELF;
         }
 
         if (interp_elf_ex.e_ident[0] != 0x7f ||
bsd-user/mmap.c +13 -12
index 1b8c8382ca..785655f319 100644
@@ -487,18 +487,19 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
        up to the targets page boundary.  */
 
     if ((qemu_real_host_page_size < qemu_host_page_size) && fd != -1) {
-       struct stat sb;
-
-       if (fstat (fd, &sb) == -1)
-           goto fail;
-
-       /* Are we trying to create a map beyond EOF?.  */
-       if (offset + len > sb.st_size) {
-           /* If so, truncate the file map at eof aligned with
-              the hosts real pagesize. Additional anonymous maps
-              will be created beyond EOF.  */
-           len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset);
-       }
+        struct stat sb;
+
+        if (fstat(fd, &sb) == -1) {
+            goto fail;
+        }
+
+        /* Are we trying to create a map beyond EOF?.  */
+        if (offset + len > sb.st_size) {
+            /* If so, truncate the file map at eof aligned with
+               the hosts real pagesize. Additional anonymous maps
+               will be created beyond EOF.  */
+            len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset);
+        }
     }
 
     if (!(flags & MAP_FIXED)) {
Signature · 1 line
2.29.1.59.gf9b6481aed
author
#3 lore raw

PATCH v4 3/4 bsd-user: do not use C99 // comments

In reply to shiliyang

This patch fixes error messages found by checkpatch.pl:
ERROR: do not use C99 // comments

---
 bsd-user/elfload.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
bsd-user/elfload.c +2 -2
index d5cab25607..2842dfe56b 100644
@@ -390,7 +390,7 @@ static const char *lookup_symbolxx(struct syminfo *s, target_ulong orig_addr)
     struct elf_sym *syms = s->disas_symtab.elf64;
 #endif
 
-    // binary search
+    /* binary search */
     struct elf_sym *sym;
 
     sym = bsearch(&orig_addr, syms, s->disas_num_syms, sizeof(*syms), symfind);
@@ -465,7 +465,7 @@ found:
     i = 0;
     while (i < nsyms) {
         bswap_sym(syms + i);
-        // Throw away entries which we do not need.
+        /* Throw away entries which we do not need. */
         if (syms[i].st_shndx == SHN_UNDEF ||
                 syms[i].st_shndx >= SHN_LORESERVE ||
                 ELF_ST_TYPE(syms[i].st_info) != STT_FUNC) {
Signature · 1 line
2.29.1.59.gf9b6481aed
#4 lore raw

Re: [PATCH V4 3/4] bsd-user: do not use C99 // comments

Same: please submit this via http://github.com/qemu-bsd-user...

Warner

Quoted 36 lines · shiliyang

This patch fixes error messages found by checkpatch.pl:
ERROR: do not use C99 // comments

---
 bsd-user/elfload.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
bsd-user/elfload.c +1 -1
index d5cab25607..2842dfe56b 100644
@@ -390,7 +390,7 @@ static const char *lookup_symbolxx(struct syminfo *s,
 target_ulong orig_addr)
     struct elf_sym *syms = s->disas_symtab.elf64;
 #endif
 
-    // binary search
+    /* binary search */
     struct elf_sym *sym;
 
     sym = bsearch(&orig_addr, syms, s->disas_num_syms, sizeof(*syms),

symfind);

bsd-user/elfload.c +1 -2
@@ -465,7 +465,7 @@ found:
     i = 0;
     while (i < nsyms) {
         bswap_sym(syms + i);
-        // Throw away entries which we do not need.
+        /* Throw away entries which we do not need. */
         if (syms[i].st_shndx == SHN_UNDEF ||
                 syms[i].st_shndx >= SHN_LORESERVE ||
                 ELF_ST_TYPE(syms[i].st_info) != STT_FUNC) {
--

2.29.1.59.gf9b6481aed

author
#5 lore raw

PATCH v4 4/4 bsd-user: space required after semicolon

In reply to shiliyang

This patch fixes error style problems found by checkpatch.pl:
ERROR: space required after that ','

---
 bsd-user/elfload.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
bsd-user/elfload.c +5 -5
index 2842dfe56b..c89c998c22 100644
@@ -636,8 +636,8 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
 
 #ifndef __FreeBSD__
     bprm->p = copy_elf_strings(1, &bprm->filename, bprm->page, bprm->p);
-    bprm->p = copy_elf_strings(bprm->envc,bprm->envp,bprm->page,bprm->p);
-    bprm->p = copy_elf_strings(bprm->argc,bprm->argv,bprm->page,bprm->p);
+    bprm->p = copy_elf_strings(bprm->envc, bprm->envp, bprm->page, bprm->p);
+    bprm->p = copy_elf_strings(bprm->argc, bprm->argv, bprm->page, bprm->p);
     if (!bprm->p) {
         retval = -E2BIG;
     }
@@ -739,7 +739,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
             if (retval >= 0) {
                 retval = lseek(interpreter_fd, 0, SEEK_SET);
                 if(retval >= 0) {
-                    retval = read(interpreter_fd,bprm->buf,128);
+                    retval = read(interpreter_fd, bprm->buf, 128);
                 }
             }
             if (retval >= 0) {
@@ -769,7 +769,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
         }
 
         if (interp_elf_ex.e_ident[0] != 0x7f ||
-                strncmp((char *)&interp_elf_ex.e_ident[1], "ELF",3) != 0) {
+                strncmp((char *)&interp_elf_ex.e_ident[1], "ELF", 3) != 0) {
             interpreter_type &= ~INTERPRETER_ELF;
         }
 
@@ -792,7 +792,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
             passed_p = passed_fileno;
 
             if (elf_interpreter) {
-                bprm->p = copy_elf_strings(1,&passed_p,bprm->page,bprm->p);
+                bprm->p = copy_elf_strings(1, &passed_p, bprm->page, bprm->p);
                 bprm->argc++;
             }
         }
Signature · 1 line
2.29.1.59.gf9b6481aed
#6 lore raw

Re: [PATCH V4 4/4] bsd-user: space required after semicolon

Can you submit this to our current fork at http://github.com/qemu-bsd-user
on the rebase-3.1 branch? Having churn like this upstream just slows us down since we have extensive changes and these will conflict.

Warner

Quoted 64 lines · shiliyang

This patch fixes error style problems found by checkpatch.pl:
ERROR: space required after that ','

---
 bsd-user/elfload.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
bsd-user/elfload.c +2 -2
index 2842dfe56b..c89c998c22 100644
@@ -636,8 +636,8 @@ int load_elf_binary(struct bsd_binprm *bprm, struct
 target_pt_regs *regs,
 
 #ifndef __FreeBSD__
     bprm->p = copy_elf_strings(1, &bprm->filename, bprm->page, bprm->p);
-    bprm->p = copy_elf_strings(bprm->envc,bprm->envp,bprm->page,bprm->p);
-    bprm->p = copy_elf_strings(bprm->argc,bprm->argv,bprm->page,bprm->p);
+    bprm->p = copy_elf_strings(bprm->envc, bprm->envp, bprm->page,
 bprm->p);
+    bprm->p = copy_elf_strings(bprm->argc, bprm->argv, bprm->page,
 bprm->p);
     if (!bprm->p) {
         retval = -E2BIG;
     }
bsd-user/elfload.c +1 -1
@@ -739,7 +739,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct
 target_pt_regs *regs,
             if (retval >= 0) {
                 retval = lseek(interpreter_fd, 0, SEEK_SET);
                 if(retval >= 0) {
-                    retval = read(interpreter_fd,bprm->buf,128);
+                    retval = read(interpreter_fd, bprm->buf, 128);
                 }
             }
             if (retval >= 0) {
bsd-user/elfload.c +1 -1
@@ -769,7 +769,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct
 target_pt_regs *regs,
         }
 
         if (interp_elf_ex.e_ident[0] != 0x7f ||
-                strncmp((char *)&interp_elf_ex.e_ident[1], "ELF",3) != 0)
 {
+                strncmp((char *)&interp_elf_ex.e_ident[1], "ELF", 3) !=
 0) {
             interpreter_type &= ~INTERPRETER_ELF;
         }
bsd-user/elfload.c +1 -1
@@ -792,7 +792,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct
 target_pt_regs *regs,
             passed_p = passed_fileno;
 
             if (elf_interpreter) {
-                bprm->p =
 copy_elf_strings(1,&passed_p,bprm->page,bprm->p);
+                bprm->p = copy_elf_strings(1, &passed_p, bprm->page,
 bprm->p);
                 bprm->argc++;
             }
         }

--
2.29.1.59.gf9b6481aed

author
#7 lore raw

Re: [PATCH V4 4/4] bsd-user: space required after semicolon

Hi Warner:
I might misunderstood it before.
So, what should I do is to make a new pull request for bsd-user-rebase-3.1 branch. Am I right? I have submitted a pull request: https://github.com/qemu-bsd-user/qemu-bsd-user/pull/4
Please review it.

Thanks.
Best regards.

Quoted 59 lines · Warner Losh

Can you submit this to our current fork at http://github.com/qemu-bsd-user <http://github.com/qemu-bsd-user> on the rebase-3.1 branch? Having churn like this upstream just slows us down since we have extensive changes and these will conflict.

Warner

On Sun, Jan 17, 2021, 7:21 PM shiliyang <[email protected] <mailto:[email protected]>> wrote:

    This patch fixes error style problems found by checkpatch.pl <http://checkpatch.pl>:
    ERROR: space required after that ','

    Signed-off-by: Liyang Shi <[email protected] <mailto:[email protected]>>
    ---
     bsd-user/elfload.c | 10 +++++-----
     1 file changed, 5 insertions(+), 5 deletions(-)

    diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
    index 2842dfe56b..c89c998c22 100644
    --- a/bsd-user/elfload.c
    +++ b/bsd-user/elfload.c
    @@ -636,8 +636,8 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,

     #ifndef __FreeBSD__
         bprm->p = copy_elf_strings(1, &bprm->filename, bprm->page, bprm->p);
    -    bprm->p = copy_elf_strings(bprm->envc,bprm->envp,bprm->page,bprm->p);
    -    bprm->p = copy_elf_strings(bprm->argc,bprm->argv,bprm->page,bprm->p);
    +    bprm->p = copy_elf_strings(bprm->envc, bprm->envp, bprm->page, bprm->p);
    +    bprm->p = copy_elf_strings(bprm->argc, bprm->argv, bprm->page, bprm->p);
         if (!bprm->p) {
             retval = -E2BIG;
         }
    @@ -739,7 +739,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
                 if (retval >= 0) {
                     retval = lseek(interpreter_fd, 0, SEEK_SET);
                     if(retval >= 0) {
    -                    retval = read(interpreter_fd,bprm->buf,128);
    +                    retval = read(interpreter_fd, bprm->buf, 128);
                     }
                 }
                 if (retval >= 0) {
    @@ -769,7 +769,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
             }

             if (interp_elf_ex.e_ident[0] != 0x7f ||
    -                strncmp((char *)&interp_elf_ex.e_ident[1], "ELF",3) != 0) {
    +                strncmp((char *)&interp_elf_ex.e_ident[1], "ELF", 3) != 0) {
                 interpreter_type &= ~INTERPRETER_ELF;
             }

    @@ -792,7 +792,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
                 passed_p = passed_fileno;

                 if (elf_interpreter) {
    -                bprm->p = copy_elf_strings(1,&passed_p,bprm->page,bprm->p);
    +                bprm->p = copy_elf_strings(1, &passed_p, bprm->page, bprm->p);
                     bprm->argc++;
                 }
             }
    -- 
    2.29.1.59.gf9b6481aed
#8 lore raw
In reply to shiliyang

Please submit these via http://github.com/qemu-bsd-user/

Quoted 26 lines · shiliyang

This patch series fixes error style problems found by checkpatch.pl.

V3->V4:
Fix code style problems with branch bsd-user-rebase-3.1.

V2->V3:
Make the patch into a series.

V1->V2:
Add cover letter message.
Fix some style error in patch file before.

Liyang Shi (4):
bsd-user: "foo * bar" should be "foo *bar"
bsd-user: suspect code indent for conditional statements
bsd-user: do not use C99 // comments
bsd-user: space required after semicolon

 bsd-user/bsdload.c |  4 ++--
 bsd-user/elfload.c | 32 ++++++++++++++++----------------
 bsd-user/mmap.c    | 25 +++++++++++++------------
 3 files changed, 31 insertions(+), 30 deletions(-)

--
2.29.1.59.gf9b6481aed