qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 0/5] bsd-user: minor cleanup patches
@ 2021-04-30 17:27 Warner Losh
  2021-04-30 17:27 ` [PULL 1/5] bsd-user: whitespace changes Warner Losh
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Warner Losh @ 2021-04-30 17:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kevans, Warner Losh

The following changes since commit ffa090bc56e73e287a63261e70ac02c0970be61a:

  target/s390x: fix s390_probe_access to check PAGE_WRITE_ORG for writeability (2021-04-23 14:10:56 +0100)

are available in the Git repository at:

  https://gitlab.com/bsdimp/qemu.git tags/pull-bsd-user-20210430

for you to fetch changes up to 58b3beb483d08066548d84eccd007b9d8bd24a2b:

  bsd-user: style tweak: Put {} around all if/else/for statements (2021-04-30 09:14:06 -0600)

----------------------------------------------------------------
bsd-user: start to cleanup the mess

A number of small cleanups to get started. All the checkpatch.pl warnings for
bsdload.c have been fixed, as well as a warning from qemu.h (though more remain
and this patch series fails the format check still). I've also fixed a
compile-time warning about a missing break.

----------------------------------------------------------------
Warner Losh (5):
      bsd-user: whitespace changes
      bsd-user: style tweak: keyword space (
      bsd-user: style tweak: return is not a function, eliminate ()
      bsd-user: put back a break; that had gone missing...
      bsd-user: style tweak: Put {} around all if/else/for statements

 bsd-user/bsdload.c | 55 +++++++++++++++++++++++++++---------------------------
 bsd-user/qemu.h    |  4 ++--
 bsd-user/syscall.c |  1 +
 3 files changed, 31 insertions(+), 29 deletions(-)

-- 
2.22.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PULL 1/5] bsd-user: whitespace changes
  2021-04-30 17:27 [PULL 0/5] bsd-user: minor cleanup patches Warner Losh
@ 2021-04-30 17:27 ` Warner Losh
  2021-04-30 17:27 ` [PULL 2/5] bsd-user: style tweak: keyword space ( Warner Losh
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Warner Losh @ 2021-04-30 17:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kevans, Richard Henderson, Warner Losh

keyword space paren, no space before ( in function calls, spaces around
operators.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsdload.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/bsd-user/bsdload.c b/bsd-user/bsdload.c
index f38c4faacf..546946b91d 100644
--- a/bsd-user/bsdload.c
+++ b/bsd-user/bsdload.c
@@ -20,11 +20,11 @@ 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;
 
-    for(i = 0; *vec; i++) {
+    for (i = 0; *vec; i++) {
         vec++;
     }
 
@@ -37,15 +37,15 @@ static int prepare_binprm(struct linux_binprm *bprm)
     int mode;
     int retval;
 
-    if(fstat(bprm->fd, &st) < 0) {
+    if (fstat(bprm->fd, &st) < 0) {
         return(-errno);
     }
 
     mode = st.st_mode;
-    if(!S_ISREG(mode)) {        /* Must be regular file */
+    if (!S_ISREG(mode)) {        /* Must be regular file */
         return(-EACCES);
     }
-    if(!(mode & 0111)) {        /* Must have at least one execute bit set */
+    if (!(mode & 0111)) {        /* Must have at least one execute bit set */
         return(-EACCES);
     }
 
@@ -53,7 +53,7 @@ static int prepare_binprm(struct linux_binprm *bprm)
     bprm->e_gid = getegid();
 
     /* Set-uid? */
-    if(mode & S_ISUID) {
+    if (mode & S_ISUID) {
         bprm->e_uid = st.st_uid;
     }
 
@@ -69,10 +69,10 @@ static int prepare_binprm(struct linux_binprm *bprm)
 
     memset(bprm->buf, 0, sizeof(bprm->buf));
     retval = lseek(bprm->fd, 0L, SEEK_SET);
-    if(retval >= 0) {
+    if (retval >= 0) {
         retval = read(bprm->fd, bprm->buf, 128);
     }
-    if(retval < 0) {
+    if (retval < 0) {
         perror("prepare_binprm");
         exit(-1);
         /* return(-errno); */
@@ -125,15 +125,15 @@ abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
     return sp;
 }
 
-int loader_exec(const char * filename, char ** argv, char ** envp,
-             struct target_pt_regs * regs, struct image_info *infop)
+int loader_exec(const char *filename, char **argv, char **envp,
+             struct target_pt_regs *regs, struct image_info *infop)
 {
     struct linux_binprm bprm;
     int retval;
     int i;
 
-    bprm.p = TARGET_PAGE_SIZE*MAX_ARG_PAGES-sizeof(unsigned int);
-    for (i=0 ; i<MAX_ARG_PAGES ; i++)       /* clear page-table */
+    bprm.p = TARGET_PAGE_SIZE * MAX_ARG_PAGES - sizeof(unsigned int);
+    for (i = 0 ; i < MAX_ARG_PAGES ; i++)       /* clear page-table */
             bprm.page[i] = NULL;
     retval = open(filename, O_RDONLY);
     if (retval < 0)
@@ -147,26 +147,26 @@ int loader_exec(const char * filename, char ** argv, char ** envp,
 
     retval = prepare_binprm(&bprm);
 
-    if(retval>=0) {
+    if (retval >= 0) {
         if (bprm.buf[0] == 0x7f
                 && bprm.buf[1] == 'E'
                 && bprm.buf[2] == 'L'
                 && bprm.buf[3] == 'F') {
-            retval = load_elf_binary(&bprm,regs,infop);
+            retval = load_elf_binary(&bprm, regs, infop);
         } else {
             fprintf(stderr, "Unknown binary format\n");
             return -1;
         }
     }
 
-    if(retval>=0) {
+    if (retval >= 0) {
         /* success.  Initialize important registers */
         do_init_thread(regs, infop);
         return retval;
     }
 
     /* Something went wrong, return the inode and free the argument pages*/
-    for (i=0 ; i<MAX_ARG_PAGES ; i++) {
+    for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
         g_free(bprm.page[i]);
     }
     return(retval);
-- 
2.22.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PULL 2/5] bsd-user: style tweak: keyword space (
  2021-04-30 17:27 [PULL 0/5] bsd-user: minor cleanup patches Warner Losh
  2021-04-30 17:27 ` [PULL 1/5] bsd-user: whitespace changes Warner Losh
@ 2021-04-30 17:27 ` Warner Losh
  2021-04-30 17:27 ` [PULL 3/5] bsd-user: style tweak: return is not a function, eliminate () Warner Losh
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Warner Losh @ 2021-04-30 17:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kevans, Richard Henderson, Warner Losh

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/qemu.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index d2bcaab741..b836b603af 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -233,7 +233,7 @@ static inline bool access_ok(int type, abi_ulong addr, abi_ulong size)
 #define __put_user(x, hptr)\
 ({\
     int size = sizeof(*hptr);\
-    switch(size) {\
+    switch (size) {\
     case 1:\
         *(uint8_t *)(hptr) = (uint8_t)(typeof(*hptr))(x);\
         break;\
@@ -255,7 +255,7 @@ static inline bool access_ok(int type, abi_ulong addr, abi_ulong size)
 #define __get_user(x, hptr) \
 ({\
     int size = sizeof(*hptr);\
-    switch(size) {\
+    switch (size) {\
     case 1:\
         x = (typeof(*hptr))*(uint8_t *)(hptr);\
         break;\
-- 
2.22.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PULL 3/5] bsd-user: style tweak: return is not a function, eliminate ()
  2021-04-30 17:27 [PULL 0/5] bsd-user: minor cleanup patches Warner Losh
  2021-04-30 17:27 ` [PULL 1/5] bsd-user: whitespace changes Warner Losh
  2021-04-30 17:27 ` [PULL 2/5] bsd-user: style tweak: keyword space ( Warner Losh
@ 2021-04-30 17:27 ` Warner Losh
  2021-04-30 17:27 ` [PULL 4/5] bsd-user: put back a break; that had gone missing Warner Losh
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Warner Losh @ 2021-04-30 17:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kevans, Richard Henderson, Warner Losh

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsdload.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/bsd-user/bsdload.c b/bsd-user/bsdload.c
index 546946b91d..fd14ffa4cd 100644
--- a/bsd-user/bsdload.c
+++ b/bsd-user/bsdload.c
@@ -28,7 +28,7 @@ static int count(char **vec)
         vec++;
     }
 
-    return(i);
+    return i;
 }
 
 static int prepare_binprm(struct linux_binprm *bprm)
@@ -38,15 +38,15 @@ static int prepare_binprm(struct linux_binprm *bprm)
     int retval;
 
     if (fstat(bprm->fd, &st) < 0) {
-        return(-errno);
+        return -errno;
     }
 
     mode = st.st_mode;
     if (!S_ISREG(mode)) {        /* Must be regular file */
-        return(-EACCES);
+        return -EACCES;
     }
     if (!(mode & 0111)) {        /* Must have at least one execute bit set */
-        return(-EACCES);
+        return -EACCES;
     }
 
     bprm->e_uid = geteuid();
@@ -75,10 +75,9 @@ static int prepare_binprm(struct linux_binprm *bprm)
     if (retval < 0) {
         perror("prepare_binprm");
         exit(-1);
-        /* return(-errno); */
     }
     else {
-        return(retval);
+        return retval;
     }
 }
 
@@ -169,5 +168,5 @@ int loader_exec(const char *filename, char **argv, char **envp,
     for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
         g_free(bprm.page[i]);
     }
-    return(retval);
+    return retval;
 }
-- 
2.22.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PULL 4/5] bsd-user: put back a break; that had gone missing...
  2021-04-30 17:27 [PULL 0/5] bsd-user: minor cleanup patches Warner Losh
                   ` (2 preceding siblings ...)
  2021-04-30 17:27 ` [PULL 3/5] bsd-user: style tweak: return is not a function, eliminate () Warner Losh
@ 2021-04-30 17:27 ` Warner Losh
  2021-04-30 17:27 ` [PULL 5/5] bsd-user: style tweak: Put {} around all if/else/for statements Warner Losh
  2021-05-04 16:04 ` [PULL 0/5] bsd-user: minor cleanup patches Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Warner Losh @ 2021-04-30 17:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kevans, Richard Henderson, Warner Losh

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/syscall.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index adc3d21b54..4abff796c7 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -199,6 +199,7 @@ static int sysctl_oldcvt(void *holdp, size_t holdlen, uint32_t kind)
 #else
     case CTLTYPE_LONG:
         *(uint64_t *)holdp = tswap64(*(long *)holdp);
+        break;
     case CTLTYPE_ULONG:
         *(uint64_t *)holdp = tswap64(*(unsigned long *)holdp);
         break;
-- 
2.22.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PULL 5/5] bsd-user: style tweak: Put {} around all if/else/for statements
  2021-04-30 17:27 [PULL 0/5] bsd-user: minor cleanup patches Warner Losh
                   ` (3 preceding siblings ...)
  2021-04-30 17:27 ` [PULL 4/5] bsd-user: put back a break; that had gone missing Warner Losh
@ 2021-04-30 17:27 ` Warner Losh
  2021-05-04 16:04 ` [PULL 0/5] bsd-user: minor cleanup patches Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Warner Losh @ 2021-04-30 17:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kevans, Richard Henderson, Warner Losh

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsdload.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/bsd-user/bsdload.c b/bsd-user/bsdload.c
index fd14ffa4cd..e1ed3b7b60 100644
--- a/bsd-user/bsdload.c
+++ b/bsd-user/bsdload.c
@@ -13,8 +13,9 @@ abi_long memcpy_to_target(abi_ulong dest, const void *src,
     void *host_ptr;
 
     host_ptr = lock_user(VERIFY_WRITE, dest, len, 0);
-    if (!host_ptr)
+    if (!host_ptr) {
         return -TARGET_EFAULT;
+    }
     memcpy(host_ptr, src, len);
     unlock_user(host_ptr, dest, 1);
     return 0;
@@ -75,8 +76,7 @@ static int prepare_binprm(struct linux_binprm *bprm)
     if (retval < 0) {
         perror("prepare_binprm");
         exit(-1);
-    }
-    else {
+    } else {
         return retval;
     }
 }
@@ -132,11 +132,13 @@ int loader_exec(const char *filename, char **argv, char **envp,
     int i;
 
     bprm.p = TARGET_PAGE_SIZE * MAX_ARG_PAGES - sizeof(unsigned int);
-    for (i = 0 ; i < MAX_ARG_PAGES ; i++)       /* clear page-table */
+    for (i = 0 ; i < MAX_ARG_PAGES ; i++) {     /* clear page-table */
             bprm.page[i] = NULL;
+    }
     retval = open(filename, O_RDONLY);
-    if (retval < 0)
+    if (retval < 0) {
         return retval;
+    }
     bprm.fd = retval;
     bprm.filename = (char *)filename;
     bprm.argc = count(argv);
-- 
2.22.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PULL 0/5] bsd-user: minor cleanup patches
  2021-04-30 17:27 [PULL 0/5] bsd-user: minor cleanup patches Warner Losh
                   ` (4 preceding siblings ...)
  2021-04-30 17:27 ` [PULL 5/5] bsd-user: style tweak: Put {} around all if/else/for statements Warner Losh
@ 2021-05-04 16:04 ` Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2021-05-04 16:04 UTC (permalink / raw)
  To: Warner Losh; +Cc: Kyle Evans, QEMU Developers

On Fri, 30 Apr 2021 at 18:46, Warner Losh <imp@bsdimp.com> wrote:
>
> The following changes since commit ffa090bc56e73e287a63261e70ac02c0970be61a:
>
>   target/s390x: fix s390_probe_access to check PAGE_WRITE_ORG for writeability (2021-04-23 14:10:56 +0100)
>
> are available in the Git repository at:
>
>   https://gitlab.com/bsdimp/qemu.git tags/pull-bsd-user-20210430
>
> for you to fetch changes up to 58b3beb483d08066548d84eccd007b9d8bd24a2b:
>
>   bsd-user: style tweak: Put {} around all if/else/for statements (2021-04-30 09:14:06 -0600)
>
> ----------------------------------------------------------------
> bsd-user: start to cleanup the mess
>
> A number of small cleanups to get started. All the checkpatch.pl warnings for
> bsdload.c have been fixed, as well as a warning from qemu.h (though more remain
> and this patch series fails the format check still). I've also fixed a
> compile-time warning about a missing break.
>
> ----------------------------------------------------------------
> Warner Losh (5):
>       bsd-user: whitespace changes
>       bsd-user: style tweak: keyword space (
>       bsd-user: style tweak: return is not a function, eliminate ()
>       bsd-user: put back a break; that had gone missing...
>       bsd-user: style tweak: Put {} around all if/else/for statements


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/6.1
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-05-04 16:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-30 17:27 [PULL 0/5] bsd-user: minor cleanup patches Warner Losh
2021-04-30 17:27 ` [PULL 1/5] bsd-user: whitespace changes Warner Losh
2021-04-30 17:27 ` [PULL 2/5] bsd-user: style tweak: keyword space ( Warner Losh
2021-04-30 17:27 ` [PULL 3/5] bsd-user: style tweak: return is not a function, eliminate () Warner Losh
2021-04-30 17:27 ` [PULL 4/5] bsd-user: put back a break; that had gone missing Warner Losh
2021-04-30 17:27 ` [PULL 5/5] bsd-user: style tweak: Put {} around all if/else/for statements Warner Losh
2021-05-04 16:04 ` [PULL 0/5] bsd-user: minor cleanup patches Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).