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

[Xen-devel] [PATCH] xl: fix incorrect display of illegal option character



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@xxxxxxx>

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

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;
         }
     }
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.