debuggers.hg

changeset 22886:3e928084336f

xl: fix incorrect display of illegal option character

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

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Andre Przywara <andre.przywara@amd.com>
date Fri Jan 28 17:56:00 2011 +0000 (2011-01-28)
parents 6d6465868420
children c5a7a40cc4f4
files tools/libxl/xl_cmdimpl.c
line diff
     1.1 --- a/tools/libxl/xl_cmdimpl.c	Fri Jan 28 17:45:24 2011 +0000
     1.2 +++ b/tools/libxl/xl_cmdimpl.c	Fri Jan 28 17:56:00 2011 +0000
     1.3 @@ -2974,7 +2974,7 @@ int main_dump_core(int argc, char **argv
     1.4              help("dump-core");
     1.5              return 0;
     1.6          default:
     1.7 -            fprintf(stderr, "option `%c' not supported.\n", opt);
     1.8 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
     1.9              break;
    1.10          }
    1.11      }
    1.12 @@ -3481,7 +3481,7 @@ int main_vcpulist(int argc, char **argv)
    1.13              help("vcpu-list");
    1.14              return 0;
    1.15          default:
    1.16 -            fprintf(stderr, "option `%c' not supported.\n", opt);
    1.17 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
    1.18              break;
    1.19          }
    1.20      }
    1.21 @@ -3572,7 +3572,7 @@ int main_vcpupin(int argc, char **argv)
    1.22              help("vcpu-pin");
    1.23              return 0;
    1.24          default:
    1.25 -            fprintf(stderr, "option `%c' not supported.\n", opt);
    1.26 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
    1.27              break;
    1.28          }
    1.29      }
    1.30 @@ -3617,7 +3617,7 @@ int main_vcpuset(int argc, char **argv)
    1.31          help("vcpu-set");
    1.32              return 0;
    1.33          default:
    1.34 -            fprintf(stderr, "option `%c' not supported.\n", opt);
    1.35 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
    1.36              break;
    1.37          }
    1.38      }
    1.39 @@ -3781,7 +3781,7 @@ int main_info(int argc, char **argv)
    1.40              numa = 1;
    1.41              break;
    1.42          default:
    1.43 -            fprintf(stderr, "option `%c' not supported.\n", opt);
    1.44 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
    1.45              break;
    1.46          }
    1.47      }
    1.48 @@ -3853,7 +3853,7 @@ int main_sched_credit(int argc, char **a
    1.49              help("sched-credit");
    1.50              return 0;
    1.51          default:
    1.52 -            fprintf(stderr, "option `%c' not supported.\n", opt);
    1.53 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
    1.54              break;
    1.55          }
    1.56      }
    1.57 @@ -3912,7 +3912,7 @@ int main_domid(int argc, char **argv)
    1.58              help("domid");
    1.59              return 0;
    1.60          default:
    1.61 -            fprintf(stderr, "option `%c' not supported.\n", opt);
    1.62 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
    1.63              break;
    1.64          }
    1.65      }
    1.66 @@ -3946,7 +3946,7 @@ int main_domname(int argc, char **argv)
    1.67              help("domname");
    1.68              return 0;
    1.69          default:
    1.70 -            fprintf(stderr, "option `%c' not supported.\n", opt);
    1.71 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
    1.72              break;
    1.73          }
    1.74      }
    1.75 @@ -3987,7 +3987,7 @@ int main_rename(int argc, char **argv)
    1.76              help("rename");
    1.77              return 0;
    1.78          default:
    1.79 -            fprintf(stderr, "option `%c' not supported.\n", opt);
    1.80 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
    1.81              break;
    1.82          }
    1.83      }
    1.84 @@ -4024,7 +4024,7 @@ int main_trigger(int argc, char **argv)
    1.85              help("trigger");
    1.86              return 0;
    1.87          default:
    1.88 -            fprintf(stderr, "option `%c' not supported.\n", opt);
    1.89 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
    1.90              break;
    1.91          }
    1.92      }
    1.93 @@ -4065,7 +4065,7 @@ int main_sysrq(int argc, char **argv)
    1.94              help("sysrq");
    1.95              return 0;
    1.96          default:
    1.97 -            fprintf(stderr, "option `%c' not supported.\n", opt);
    1.98 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
    1.99              break;
   1.100          }
   1.101      }
   1.102 @@ -4165,7 +4165,7 @@ int main_top(int argc, char **argv)
   1.103              help("top");
   1.104              return 0;
   1.105          default:
   1.106 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.107 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.108              break;
   1.109          }
   1.110      }
   1.111 @@ -4188,7 +4188,7 @@ int main_networkattach(int argc, char **
   1.112              help("network-attach");
   1.113              return 0;
   1.114          default:
   1.115 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.116 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.117              break;
   1.118          }
   1.119      }
   1.120 @@ -4269,7 +4269,7 @@ int main_networklist(int argc, char **ar
   1.121                  help("network-list");
   1.122                  return 0;
   1.123              default:
   1.124 -                fprintf(stderr, "option `%c' not supported.\n", opt);
   1.125 +                fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.126                  break;
   1.127          }
   1.128      }
   1.129 @@ -4318,7 +4318,7 @@ int main_networkdetach(int argc, char **
   1.130              help("network-detach");
   1.131              return 0;
   1.132          default:
   1.133 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.134 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.135              break;
   1.136          }
   1.137      }
   1.138 @@ -4364,7 +4364,7 @@ int main_blockattach(int argc, char **ar
   1.139              help("block-attach");
   1.140              return 0;
   1.141          default:
   1.142 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.143 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.144              break;
   1.145          }
   1.146      }
   1.147 @@ -4437,7 +4437,7 @@ int main_blocklist(int argc, char **argv
   1.148              help("block-list");
   1.149              return 0;
   1.150          default:
   1.151 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.152 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.153              break;
   1.154          }
   1.155      }
   1.156 @@ -4483,7 +4483,7 @@ int main_blockdetach(int argc, char **ar
   1.157              help("block-detach");
   1.158              return 0;
   1.159          default:
   1.160 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.161 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.162              break;
   1.163          }
   1.164      }
   1.165 @@ -4522,7 +4522,7 @@ int main_network2attach(int argc, char *
   1.166              help("network2-attach");
   1.167              return 0;
   1.168          default:
   1.169 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.170 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.171              break;
   1.172          }
   1.173      }
   1.174 @@ -4615,7 +4615,7 @@ int main_network2list(int argc, char **a
   1.175              help("network2-list");
   1.176              return 0;
   1.177          default:
   1.178 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.179 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.180              break;
   1.181          }
   1.182      }
   1.183 @@ -4659,7 +4659,7 @@ int main_network2detach(int argc, char *
   1.184              help("network2-detach");
   1.185              return 0;
   1.186          default:
   1.187 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.188 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.189              break;
   1.190          }
   1.191      }
   1.192 @@ -4858,7 +4858,7 @@ int main_uptime(int argc, char **argv)
   1.193              help("uptime");
   1.194              return 0;
   1.195          default:
   1.196 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.197 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.198              break;
   1.199          }
   1.200      }
   1.201 @@ -4893,7 +4893,7 @@ int main_tmem_list(int argc, char **argv
   1.202              help("tmem-list");
   1.203              return 0;
   1.204          default:
   1.205 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.206 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.207              break;
   1.208          }
   1.209      }
   1.210 @@ -4934,7 +4934,7 @@ int main_tmem_freeze(int argc, char **ar
   1.211              help("tmem-freeze");
   1.212              return 0;
   1.213          default:
   1.214 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.215 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.216              break;
   1.217          }
   1.218      }
   1.219 @@ -4970,7 +4970,7 @@ int main_tmem_destroy(int argc, char **a
   1.220              help("tmem-destroy");
   1.221              return 0;
   1.222          default:
   1.223 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.224 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.225              break;
   1.226          }
   1.227      }
   1.228 @@ -5006,7 +5006,7 @@ int main_tmem_thaw(int argc, char **argv
   1.229              help("tmem-thaw");
   1.230              return 0;
   1.231          default:
   1.232 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.233 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.234              break;
   1.235          }
   1.236      }
   1.237 @@ -5056,7 +5056,7 @@ int main_tmem_set(int argc, char **argv)
   1.238              help("tmem-set");
   1.239              return 0;
   1.240          default:
   1.241 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.242 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.243              break;
   1.244          }
   1.245      }
   1.246 @@ -5114,7 +5114,7 @@ int main_tmem_shared_auth(int argc, char
   1.247              help("tmem-shared-auth");
   1.248              return 0;
   1.249          default:
   1.250 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.251 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.252              break;
   1.253          }
   1.254      }
   1.255 @@ -5159,7 +5159,7 @@ int main_tmem_freeable(int argc, char **
   1.256              help("tmem-freeable");
   1.257              return 0;
   1.258          default:
   1.259 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.260 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.261              break;
   1.262          }
   1.263      }
   1.264 @@ -5487,7 +5487,7 @@ int main_cpupooldestroy(int argc, char *
   1.265              help("cpupool-destroy");
   1.266              return 0;
   1.267          default:
   1.268 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.269 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.270              break;
   1.271          }
   1.272      }
   1.273 @@ -5521,7 +5521,7 @@ int main_cpupoolrename(int argc, char **
   1.274              help("cpupool-rename");
   1.275              return 0;
   1.276          default:
   1.277 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.278 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.279              break;
   1.280          }
   1.281      }
   1.282 @@ -5564,7 +5564,7 @@ int main_cpupoolcpuadd(int argc, char **
   1.283              help("cpupool-cpu-add");
   1.284              return 0;
   1.285          default:
   1.286 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.287 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.288              break;
   1.289          }
   1.290      }
   1.291 @@ -5627,7 +5627,7 @@ int main_cpupoolcpuremove(int argc, char
   1.292              help("cpupool-cpu-remove");
   1.293              return 0;
   1.294          default:
   1.295 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.296 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.297              break;
   1.298          }
   1.299      }
   1.300 @@ -5689,7 +5689,7 @@ int main_cpupoolmigrate(int argc, char *
   1.301              help("cpupool-migrate");
   1.302              return 0;
   1.303          default:
   1.304 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.305 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.306              break;
   1.307          }
   1.308      }
   1.309 @@ -5746,7 +5746,7 @@ int main_cpupoolnumasplit(int argc, char
   1.310              help("cpupool-numa-split");
   1.311              return 0;
   1.312          default:
   1.313 -            fprintf(stderr, "option `%c' not supported.\n", opt);
   1.314 +            fprintf(stderr, "option `%c' not supported.\n", optopt);
   1.315              break;
   1.316          }
   1.317      }