Skip to contentSkip to conversation

vl.c && linux-user/main.c : removed **envp from main() arguments

PATCH Superseded Yoni Bettan 4 participants 7 messages Nov 21, 2017 – Dec 18, 2017

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vl.c && linux-user/main.c : removed **envp from main() arguments

* it was added on 2008 902b3d5c392bb6f48ef340ad8ecc3311705d2800 when introduced cache-utils.[ch]
* since then cache-utils.[ch] were removed but **envp was left behind

---
 linux-user/main.c | 2 +-
 vl.c              | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
linux-user/main.c +1 -1
index aa02f25b85..ca5628c1ca 100644
@@ -4233,7 +4233,7 @@ static int parse_args(int argc, char **argv)
     return optind;
 }
 
-int main(int argc, char **argv, char **envp)
+int main(int argc, char **argv)
 {
     struct target_pt_regs regs1, *regs = &regs1;
     struct image_info info1, *info = &info1;
vl.c +3 -3
index 1ad1c04637..9667756ccc 100644
@@ -35,10 +35,10 @@
 #ifdef CONFIG_SDL
 #if defined(__APPLE__) || defined(main)
 #include <SDL.h>
-int qemu_main(int argc, char **argv, char **envp);
+int qemu_main(int argc, char **argv);
 int main(int argc, char **argv)
 {
-    return qemu_main(argc, argv, NULL);
+    return qemu_main(argc, argv);
 }
 #undef main
 #define main qemu_main
@@ -3088,7 +3088,7 @@ static void register_global_properties(MachineState *ms)
     user_register_global_props();
 }
 
-int main(int argc, char **argv, char **envp)
+int main(int argc, char **argv)
 {
     int i;
     int snapshot, linux_boot;
Signature · 1 line
2.13.6
#1 lore raw
This series seems to have some coding style problems. See output below for more information:

Hi,

This series seems to have some coding style problems. See output below for more information:

Subject: [Qemu-devel] [PATCH] vl.c && linux-user/main.c : removed **envp from main() arguments
Type: series
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
7657b24e5a vl.c && linux-user/main.c : removed **envp from main() arguments

=== OUTPUT BEGIN ===
Checking PATCH 1/1: vl.c && linux-user/main.c : removed **envp from main() arguments...
ERROR: externs should be avoided in .c files
#37: FILE: vl.c:38:
+int qemu_main(int argc, char **argv);

total: 1 errors, 0 warnings, 28 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

#2 lore raw
In reply to Yoni Bettan

Le 21/11/2017 à 07:41, Yoni Bettan a écrit :

Quoted 31 lines

* it was added on 2008 902b3d5c392bb6f48ef340ad8ecc3311705d2800 when introduced cache-utils.[ch]
* since then cache-utils.[ch] were removed but **envp was left behind

---
 linux-user/main.c | 2 +-
 vl.c              | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
linux-user/main.c +1 -1
index aa02f25b85..ca5628c1ca 100644
@@ -4233,7 +4233,7 @@ static int parse_args(int argc, char **argv)
     return optind;
 }
 
-int main(int argc, char **argv, char **envp)
+int main(int argc, char **argv)
 {
     struct target_pt_regs regs1, *regs = &regs1;
     struct image_info info1, *info = &info1;
vl.c +0 -0
index 1ad1c04637..9667756ccc 100644
@@ -35,10 +35,10 @@
 #ifdef CONFIG_SDL
 #if defined(__APPLE__) || defined(main)

vl.c line 44

Quoted 10 lines
vl.c +2 -2
 #include <SDL.h>
-int qemu_main(int argc, char **argv, char **envp);
+int qemu_main(int argc, char **argv);
 int main(int argc, char **argv)
 {
-    return qemu_main(argc, argv, NULL);
+    return qemu_main(argc, argv);
 }
 #undef main
 #define main qemu_main

I think this part can be removed now. As it seems it has been added because of the envp parameter.

Thanks,
Laurent

#3 lore raw
Quoted 36 lines · Laurent Vivier

Le 21/11/2017 à 07:41, Yoni Bettan a écrit :

Quoted 35 lines

* it was added on 2008 902b3d5c392bb6f48ef340ad8ecc3311705d2800 when introduced cache-utils.[ch]
* since then cache-utils.[ch] were removed but **envp was left behind

---
  linux-user/main.c | 2 +-
  vl.c              | 6 +++---
  2 files changed, 4 insertions(+), 4 deletions(-)
linux-user/main.c +1 -1
index aa02f25b85..ca5628c1ca 100644
@@ -4233,7 +4233,7 @@ static int parse_args(int argc, char **argv)
      return optind;
  }
 
-int main(int argc, char **argv, char **envp)
+int main(int argc, char **argv)
  {
      struct target_pt_regs regs1, *regs = &regs1;
      struct image_info info1, *info = &info1;
vl.c +1 -1
index 1ad1c04637..9667756ccc 100644
@@ -35,10 +35,10 @@
  #ifdef CONFIG_SDL
  #if defined(__APPLE__) || defined(main)
  #include <SDL.h>
-int qemu_main(int argc, char **argv, char **envp);
+int qemu_main(int argc, char **argv);
  int main(int argc, char **argv)
Quoted 8 lines

vl.c line 44

Quoted 6 lines
vl.c +1 -1
  {
-    return qemu_main(argc, argv, NULL);
+    return qemu_main(argc, argv);
  }
  #undef main
  #define main qemu_main

I think this part can be removed now. As it seems it has been added because of the envp parameter.

Thanks Laurent for your response and sorry for my late response. I think this part was added for another purpose as described here 880fec5d086

As i see it the env param was added in 2008 in order to support cache-utils as shown in 902b3d5c392bb6f48ef340ad8ecc3311705d2800 and in 2009 another main function was added in order to unbreak SDL on Mac-OS X and the env param was added only for consistency I suppose...

What do you think?

Thanks,
Yoni

Quoted 2 lines

Thanks,
Laurent

#4 lore raw

Le 18/12/2017 à 07:07, Yoni Bettan a écrit :

Quoted 51 lines · Laurent Vivier
Quoted 35 lines

Le 21/11/2017 à 07:41, Yoni Bettan a écrit :

Quoted 34 lines

         * it was added on 2008 902b3d5c392bb6f48ef340ad8ecc3311705d2800 when introduced cache-utils.[ch]
         * since then cache-utils.[ch] were removed but **envp was left behind

---
  linux-user/main.c | 2 +-
  vl.c              | 6 +++---

  2 files changed, 4 insertions(+), 4 deletions(-)
linux-user/main.c +1 -0
index aa02f25b85..ca5628c1ca 100644
@@ -4233,7 +4233,7 @@ static int parse_args(int argc, char **argv)
       return optind;
   }
   -int main(int argc, char **argv, char **envp)
+int main(int argc, char **argv)
   {
       struct target_pt_regs regs1, *regs = &regs1;
       struct image_info info1, *info = &info1;
vl.c +1 -1
index 1ad1c04637..9667756ccc 100644
@@ -35,10 +35,10 @@
   #ifdef CONFIG_SDL
   #if defined(__APPLE__) || defined(main)
   #include <SDL.h>
-int qemu_main(int argc, char **argv, char **envp);
+int qemu_main(int argc, char **argv);
   int main(int argc, char **argv)
Quoted 8 lines

vl.c line 44

Quoted 6 lines
vl.c +1 -1
   {
-    return qemu_main(argc, argv, NULL);
+    return qemu_main(argc, argv);
   }
   #undef main
   #define main qemu_main

I think this part can be removed now. As it seems it has been added because of the envp parameter.

Thanks Laurent for your response and sorry for my late response. I think this part was added for another purpose as described here 880fec5d086

Quoted 7 lines

As i see it the env param was added in 2008 in order to support cache-utils as shown in 902b3d5c392bb6f48ef340ad8ecc3311705d2800 and in 2009 another main function was added in order to unbreak SDL on Mac-OS X and the env param
was added only for consistency I suppose...

What do you think?

I think we don't need it anymore as there is no difference betweent qemu_main() and main().

Thanks,
Laurent

#5 lore raw
Quoted 2 lines · Laurent Vivier

I think we don't need it anymore as there is no difference betweent qemu_main() and main().

You need to be a bit cautious there to avoid breaking the OSX code in ui/cocoa.m, which has its own version of main() which kicks off the GUI code and then eventually calls qemu_main() later.

thanks
-- PMM

#6 lore raw

Le 18/12/2017 à 13:30, Peter Maydell a écrit :

Quoted 8 lines · Laurent Vivier
Quoted 2 lines

I think we don't need it anymore as there is no difference betweent qemu_main() and main().

You need to be a bit cautious there to avoid breaking the OSX code in ui/cocoa.m, which has its own version of main() which kicks off the GUI code and then eventually calls qemu_main() later.

Yes, you're right. cocoa.m needs qemu_main() because there is already a main() inside. So we can't remove qemu_main().

Thanks,
Laurent