All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@amd.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH] xl: fix incorrect display of illegal option character
Date: Fri, 28 Jan 2011 09:49:14 +0100	[thread overview]
Message-ID: <4D42830A.3070104@amd.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1237 bytes --]

Hi,

according to the getopt(3) manpage (and to my testing) getopt returns 
'?' if an unknown option character is found and stores the insulting 
character in optopt.
This patch fixes the broken output in such a situation:

root@dosorca:/data/images# xl vcpu-list -j
option `?' not supported.
Name                  ID  VCPU   CPU State   Time(s) CPU Affinity
Domain-0               0     0    0   -b-     193.1  any cpu

turns into:

root@dosorca:/data/images# xl vcpu-list -j
option `j' not supported.
Name                  ID  VCPU   CPU State   Time(s) CPU Affinity
Domain-0               0     0    0   -b-     193.1  any cpu

Please apply to 4.1.0-rc.

By the way: some command parsers totally omit the faulting character and 
just output "option not supported."
Would you still accept a patch which turns all of those occurrences into 
the upper, more verbose form?
Especially as those conditions are not considered fatal and the command 
execution continues anyway, I found it rather confusing to read an 
unspecific error message without giving me a clue what I did wrong.

Regards,
Andre.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>

-- 
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany


[-- Attachment #2: xl_fix_illegal_char_display.patch --]
[-- Type: text/x-patch, Size: 11197 bytes --]

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 6341767..8e713be 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -2955,7 +2955,7 @@ int main_dump_core(int argc, char **argv)
             help("dump-core");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -3462,7 +3462,7 @@ int main_vcpulist(int argc, char **argv)
             help("vcpu-list");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -3553,7 +3553,7 @@ int main_vcpupin(int argc, char **argv)
             help("vcpu-pin");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -3598,7 +3598,7 @@ int main_vcpuset(int argc, char **argv)
         help("vcpu-set");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -3762,7 +3762,7 @@ int main_info(int argc, char **argv)
             numa = 1;
             break;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -3834,7 +3834,7 @@ int main_sched_credit(int argc, char **argv)
             help("sched-credit");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -3893,7 +3893,7 @@ int main_domid(int argc, char **argv)
             help("domid");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -3927,7 +3927,7 @@ int main_domname(int argc, char **argv)
             help("domname");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -3968,7 +3968,7 @@ int main_rename(int argc, char **argv)
             help("rename");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4005,7 +4005,7 @@ int main_trigger(int argc, char **argv)
             help("trigger");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4046,7 +4046,7 @@ int main_sysrq(int argc, char **argv)
             help("sysrq");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4146,7 +4146,7 @@ int main_top(int argc, char **argv)
             help("top");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4169,7 +4169,7 @@ int main_networkattach(int argc, char **argv)
             help("network-attach");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4250,7 +4250,7 @@ int main_networklist(int argc, char **argv)
                 help("network-list");
                 return 0;
             default:
-                fprintf(stderr, "option `%c' not supported.\n", opt);
+                fprintf(stderr, "option `%c' not supported.\n", optopt);
                 break;
         }
     }
@@ -4299,7 +4299,7 @@ int main_networkdetach(int argc, char **argv)
             help("network-detach");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4345,7 +4345,7 @@ int main_blockattach(int argc, char **argv)
             help("block-attach");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4418,7 +4418,7 @@ int main_blocklist(int argc, char **argv)
             help("block-list");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4464,7 +4464,7 @@ int main_blockdetach(int argc, char **argv)
             help("block-detach");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4503,7 +4503,7 @@ int main_network2attach(int argc, char **argv)
             help("network2-attach");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4596,7 +4596,7 @@ int main_network2list(int argc, char **argv)
             help("network2-list");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4640,7 +4640,7 @@ int main_network2detach(int argc, char **argv)
             help("network2-detach");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4839,7 +4839,7 @@ int main_uptime(int argc, char **argv)
             help("uptime");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4874,7 +4874,7 @@ int main_tmem_list(int argc, char **argv)
             help("tmem-list");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4915,7 +4915,7 @@ int main_tmem_freeze(int argc, char **argv)
             help("tmem-freeze");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4951,7 +4951,7 @@ int main_tmem_destroy(int argc, char **argv)
             help("tmem-destroy");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -4987,7 +4987,7 @@ int main_tmem_thaw(int argc, char **argv)
             help("tmem-thaw");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -5037,7 +5037,7 @@ int main_tmem_set(int argc, char **argv)
             help("tmem-set");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -5095,7 +5095,7 @@ int main_tmem_shared_auth(int argc, char **argv)
             help("tmem-shared-auth");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -5140,7 +5140,7 @@ int main_tmem_freeable(int argc, char **argv)
             help("tmem-freeable");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -5468,7 +5468,7 @@ int main_cpupooldestroy(int argc, char **argv)
             help("cpupool-destroy");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -5502,7 +5502,7 @@ int main_cpupoolrename(int argc, char **argv)
             help("cpupool-rename");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -5545,7 +5545,7 @@ int main_cpupoolcpuadd(int argc, char **argv)
             help("cpupool-cpu-add");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -5608,7 +5608,7 @@ int main_cpupoolcpuremove(int argc, char **argv)
             help("cpupool-cpu-remove");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -5670,7 +5670,7 @@ int main_cpupoolmigrate(int argc, char **argv)
             help("cpupool-migrate");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }
@@ -5727,7 +5727,7 @@ int main_cpupoolnumasplit(int argc, char **argv)
             help("cpupool-numa-split");
             return 0;
         default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
             break;
         }
     }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2011-01-28  8:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-28  8:49 Andre Przywara [this message]
2011-01-28 17:57 ` [PATCH] xl: fix incorrect display of illegal option character Ian Jackson
2011-01-28 22:53   ` [PATCH] xl: output " Andre Przywara
2011-02-01 19:06     ` Ian Jackson

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=4D42830A.3070104@amd.com \
    --to=andre.przywara@amd.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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.