Le 19/12/2017 à 14:05, Yoni Bettan a écrit : > > > On 12/19/2017 12:21 PM, Laurent Vivier wrote: >> Le 19/12/2017 à 11:11, Yoni Bettan a écrit : >>> it was added on 2008 902b3d5c39 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 >>> >>> Signed-off-by: Yoni Bettan <ybet...@redhat.com> >>> --- >>> >>> V2 -> V3: >>> since ui/cocoa.c rename main() is using qemu_main() >>> ,because it uses it >>> inside its main() function, the function qemu_main() can't be >>> removed >>> >>> V1 -> V2: >>> >>> removed the ui/cocoa.c renaming of main() function since i >>> thought that we >>> no longer need qemu_main() >>> >>> >>> include/qemu-common.h | 2 +- >>> linux-user/main.c | 2 +- >>> ui/cocoa.m | 5 ++--- >>> vl.c | 7 +++---- >>> 4 files changed, 7 insertions(+), 9 deletions(-) >>> >> ... >>> diff --git a/vl.c b/vl.c >>> index fc8bd9372f..ea17cc34f6 100644 >>> --- a/vl.c >>> +++ b/vl.c >>> @@ -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 >> >> I'm really sorry, but I really think we can remove this part. > > Can you please show what exact lines you think can be removed? > If you meant that the entire part can be removed then how can > we rename main to qemu_main (in the CONFIG_COCA part) if qemu_main is > not defined?
Yes, the entire part can be removed. The following lines will declare the qemu_main for COCOA: >> >> 48 #ifdef CONFIG_COCOA >> 49 #undef main >> 50 #define main qemu_main >> 51 #endif /* CONFIG_COCOA */ The C preprocessor will replace: int main(int argc, char **argv, char **envp) { ... by int qemu_main(int argc, char **argv, char **envp) { ... To check, you can try: -----8<---------------- main.c #define main qemu_main int main(void) { return 0; } -----8<---------------- main.c then: cc -E main.c # 1 "main.c" # 1 "<built-in>" # 1 "<command-line>" # 31 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 32 "<command-line>" 2 # 1 "main.c" int qemu_main(void) { return 0; } Thanks, Laurent