All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, sw@weilnetz.de,
	riku.voipio@iki.fi, agraf@suse.de, paul@codesourcery.com,
	j.schauer@email.de, Thomas Schwinge <thomas@codesourcery.com>
Subject: [Qemu-devel] [PATCH 3/4] linux-user: Tell handler_arg_* which context they're invoked from.
Date: Wed, 29 May 2013 15:50:33 +0200	[thread overview]
Message-ID: <1369835434-27727-4-git-send-email-thomas@codesourcery.com> (raw)
In-Reply-To: <1369835434-27727-1-git-send-email-thomas@codesourcery.com>

Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
---
 linux-user/main.c |   47 ++++++++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 21 deletions(-)

diff --git linux-user/main.c linux-user/main.c
index a0ea161..b7d49f4 100644
--- linux-user/main.c
+++ linux-user/main.c
@@ -3180,12 +3180,17 @@ void init_task_state(TaskState *ts)
     ts->sigqueue_table[i].next = NULL;
 }
 
-static void handle_arg_help(const char *arg)
+typedef enum {
+    ARG_ORIGIN_ENV,
+    ARG_ORIGIN_CMDLINE
+} arg_origin;
+
+static void handle_arg_help(arg_origin whence, const char *arg)
 {
     usage();
 }
 
-static void handle_arg_log(const char *arg)
+static void handle_arg_log(arg_origin whence, const char *arg)
 {
     int mask;
 
@@ -3197,31 +3202,31 @@ static void handle_arg_log(const char *arg)
     qemu_set_log(mask);
 }
 
-static void handle_arg_log_filename(const char *arg)
+static void handle_arg_log_filename(arg_origin whence, const char *arg)
 {
     qemu_set_log_filename(arg);
 }
 
-static void handle_arg_set_env(const char *arg)
+static void handle_arg_set_env(arg_origin whence, const char *arg)
 {
     if (envlist_parse_set(envlist, arg) != 0) {
         usage();
     }
 }
 
-static void handle_arg_unset_env(const char *arg)
+static void handle_arg_unset_env(arg_origin whence, const char *arg)
 {
     if (envlist_parse_unset(envlist, arg) != 0) {
         usage();
     }
 }
 
-static void handle_arg_argv0(const char *arg)
+static void handle_arg_argv0(arg_origin whence, const char *arg)
 {
     argv0 = strdup(arg);
 }
 
-static void handle_arg_stack_size(const char *arg)
+static void handle_arg_stack_size(arg_origin whence, const char *arg)
 {
     char *p;
     guest_stack_size = strtoul(arg, &p, 0);
@@ -3236,12 +3241,12 @@ static void handle_arg_stack_size(const char *arg)
     }
 }
 
-static void handle_arg_ld_prefix(const char *arg)
+static void handle_arg_ld_prefix(arg_origin whence, const char *arg)
 {
     interp_prefix = strdup(arg);
 }
 
-static void handle_arg_pagesize(const char *arg)
+static void handle_arg_pagesize(arg_origin whence, const char *arg)
 {
     qemu_host_page_size = atoi(arg);
     if (qemu_host_page_size == 0 ||
@@ -3251,17 +3256,17 @@ static void handle_arg_pagesize(const char *arg)
     }
 }
 
-static void handle_arg_gdb(const char *arg)
+static void handle_arg_gdb(arg_origin whence, const char *arg)
 {
     gdbstub_port = atoi(arg);
 }
 
-static void handle_arg_uname(const char *arg)
+static void handle_arg_uname(arg_origin whence, const char *arg)
 {
     qemu_uname_release = strdup(arg);
 }
 
-static void handle_arg_cpu(const char *arg)
+static void handle_arg_cpu(arg_origin whence, const char *arg)
 {
     cpu_model = strdup(arg);
     if (cpu_model == NULL || is_help_option(cpu_model)) {
@@ -3274,13 +3279,13 @@ static void handle_arg_cpu(const char *arg)
 }
 
 #if defined(CONFIG_USE_GUEST_BASE)
-static void handle_arg_guest_base(const char *arg)
+static void handle_arg_guest_base(arg_origin whence, const char *arg)
 {
     guest_base = strtol(arg, NULL, 0);
     have_guest_base = 1;
 }
 
-static void handle_arg_reserved_va(const char *arg)
+static void handle_arg_reserved_va(arg_origin whence, const char *arg)
 {
     char *p;
     int shift = 0;
@@ -3317,17 +3322,17 @@ static void handle_arg_reserved_va(const char *arg)
 }
 #endif
 
-static void handle_arg_singlestep(const char *arg)
+static void handle_arg_singlestep(arg_origin whence, const char *arg)
 {
     singlestep = 1;
 }
 
-static void handle_arg_strace(const char *arg)
+static void handle_arg_strace(arg_origin whence, const char *arg)
 {
     do_strace = 1;
 }
 
-static void handle_arg_version(const char *arg)
+static void handle_arg_version(arg_origin whence, const char *arg)
 {
     printf("qemu-" TARGET_ARCH " version " QEMU_VERSION QEMU_PKGVERSION
            ", Copyright (c) 2003-2008 Fabrice Bellard\n");
@@ -3338,7 +3343,7 @@ struct qemu_argument {
     const char *argv;
     const char *env;
     bool has_arg;
-    void (*handle_opt)(const char *arg);
+    void (*handle_opt)(arg_origin whence, const char *arg);
     const char *example;
     const char *help;
 };
@@ -3467,7 +3472,7 @@ static int parse_args(int argc, char **argv)
 
         r = getenv(arginfo->env);
         if (r != NULL) {
-            arginfo->handle_opt(r);
+            arginfo->handle_opt(ARG_ORIGIN_ENV, r);
         }
     }
 
@@ -3492,10 +3497,10 @@ static int parse_args(int argc, char **argv)
                     if (optind >= argc) {
                         usage();
                     }
-                    arginfo->handle_opt(argv[optind]);
+                    arginfo->handle_opt(ARG_ORIGIN_CMDLINE, argv[optind]);
                     optind++;
                 } else {
-                    arginfo->handle_opt(NULL);
+                    arginfo->handle_opt(ARG_ORIGIN_CMDLINE, NULL);
                 }
                 break;
             }
-- 
1.7.10.4

  parent reply	other threads:[~2013-05-29 13:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-29 13:50 [Qemu-devel] [PATCH, resend] linux-user: environment variables Thomas Schwinge
2013-05-29 13:50 ` [Qemu-devel] [PATCH 1/4] util/envlist: Properly forward a callback's error in envlist_parse Thomas Schwinge
2013-06-27 17:36   ` Peter Maydell
2013-05-29 13:50 ` [Qemu-devel] [PATCH 2/4] linux-user: Use existing envlist_parse_set/envlist_parse_unset interface Thomas Schwinge
2013-06-27 17:49   ` Peter Maydell
2013-05-29 13:50 ` Thomas Schwinge [this message]
2013-05-29 13:50 ` [Qemu-devel] [PATCH 4/4] linux-user: Restore original behavior of the -E and -U command-line options Thomas Schwinge
2013-06-14  1:08   ` Alexander Graf
2013-06-27 17:54   ` Peter Maydell
2013-06-07 15:44 ` [Qemu-devel] [PATCH, resend] linux-user: environment variables Thomas Schwinge
  -- strict thread matches above, loose matches on Subject: below --
2013-04-25 12:22 [Qemu-devel] Environment variables for user-mode QEMU Riku Voipio
2013-04-24 16:11 ` Thomas Schwinge
2013-04-25 15:06   ` [Qemu-devel] [PATCH 1/4] util/envlist: Properly forward a callback's error in envlist_parse Thomas Schwinge
2013-04-25 15:06     ` [Qemu-devel] [PATCH 3/4] linux-user: Tell handler_arg_* which context they're invoked from Thomas Schwinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369835434-27727-4-git-send-email-thomas@codesourcery.com \
    --to=thomas@codesourcery.com \
    --cc=agraf@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=j.schauer@email.de \
    --cc=paul@codesourcery.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.