qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH V2] vl.c && linux-user/main.c : removed **envp f


From: Yoni Bettan
Subject: Re: [Qemu-devel] [PATCH V2] vl.c && linux-user/main.c : removed **envp from main() arguments
Date: Mon, 18 Dec 2017 15:13:40 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0



On 12/18/2017 02:54 PM, Peter Maydell wrote:
On 18 December 2017 at 12:49, Yoni Bettan <address@hidden> wrote:
          * it was added on 2008 902b3d5c392bb6f48ef340ad8ecc3311705d2800
            when introduced cache-utils.[ch]

          * since then cache-utils.[ch] were removed but **envp was left
            behind

         * by the way "to be portable it is best to write main to take two
           arguments, and use the value of environ" according to
           https://www.gnu.org/software/libc/manual/html_node/Program-\
                 Arguments.html#Program-Arguments
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 330ccebf90..851a2dcd06 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -25,7 +25,6 @@
  #include "qemu/osdep.h"

  #import <Cocoa/Cocoa.h>
-#include <crt_externs.h>

  #include "qemu-common.h"
  #include "ui/console.h"
@@ -1050,7 +1049,7 @@ QemuCocoaView *cocoaView;
      COCOA_DEBUG("QemuCocoaAppController: startEmulationWithArgc\n");

      int status;
-    status = qemu_main(argc, argv, *_NSGetEnviron());
+    status = main(argc, argv);
      exit(status);
  }

@@ -1391,7 +1390,7 @@ int main (int argc, const char * argv[]) {
                  !strcmp(opt, "-curses") ||
                  !strcmp(opt, "-display") ||
                  !strcmp(opt, "-qtest")) {
-                return qemu_main(gArgc, gArgv, *_NSGetEnviron());
+                return main(gArgc, gArgv);
              }
          }
      }
Did you test this on OSX? I'm pretty sure it will break,
because now the main() function in ui/cocoa.m will
recursively call itself, rather than calling the
function in vl.c. (Either that or it just won't
link at all because there are two main() functions.)

I didn't checked it on OSX.
I was actually convinced it is Ok but when  I rethink it
I understand that on Mac OSX the third argument is required (char **envp)
as it seems to use it here:  "return qemu_main(gArgc, gArgv, *_NSGetEnviron());"
so the patch *idea* will literally break ui/coca.m.

Do you agree?

Thanks,
Yoni

thanks
-- PMM




reply via email to

[Prev in Thread] Current Thread [Next in Thread]