Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- tools/virsh-domain-monitor.c | 6 ++--- tools/virsh-domain.c | 12 ++++----- tools/virsh-host.c | 2 +- tools/virsh-nodedev.c | 6 ++--- tools/virsh-secret.c | 2 +- tools/virsh.c | 4 +-- tools/virt-admin.c | 4 +-- tools/vsh.c | 50 +++++++++++++++++++----------------- 8 files changed, 45 insertions(+), 41 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 76843005b2..150e6ec806 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -452,7 +452,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) all = vshCommandOptBool(cmd, "all"); if (!all && vshCommandOptStringQuiet(ctl, cmd, "device", &device) <= 0) { - vshError(ctl, "command 'domblkinfo' requires <device> option"); + vshError(ctl, "%s", _("command 'domblkinfo' requires <device> option")); return false; } @@ -604,7 +604,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) target = virXPathString("string(./target/@dev)", ctxt); if (!target) { - vshError(ctl, "unable to query block list"); + vshError(ctl, "%s", _("unable to query block list")); return false; } @@ -616,7 +616,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) if (!(namespace = virXPathString("string(./source/@namespace)", ctxt)) || !(addrNode = virXPathNode("./source/address", ctxt)) || virPCIDeviceAddressParseXML(addrNode, &addr) < 0) { - vshError(ctl, "Unable to query NVMe disk address"); + vshError(ctl, "%s", _("Unable to query NVMe disk address")); return false; } diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 171bc0ce17..e20888f2c2 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7915,7 +7915,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) goto failed_stats; if (cpu >= max_id) { - vshError(ctl, "Start CPU %d is out of range (min: 0, max: %d)", + vshError(ctl, _("Start CPU %1$d is out of range (min: 0, max: %2$d)"), cpu, max_id - 1); goto cleanup; } @@ -9787,7 +9787,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd) resultjson = virJSONValueFromString(result); if (returnval && !resultjson) { - vshError(ctl, "failed to parse JSON returned by qemu"); + vshError(ctl, "%s", _("failed to parse JSON returned by qemu")); return false; } } @@ -9800,7 +9800,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd) if (returnval) { if (!(formatjson = virJSONValueObjectGet(resultjson, "return"))) { - vshError(ctl, "'return' member missing"); + vshError(ctl, "%s", _("'return' member missing")); return false; } } else { @@ -10859,7 +10859,7 @@ doMigrate(void *opaque) if (flags & VIR_MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES && !(flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC))) { - vshError(ctl, "'--copy-storage-synchronous-writes' requires one of '--copy-storage-all', '--copy-storage-inc'"); + vshError(ctl, "%s", _("'--copy-storage-synchronous-writes' requires one of '--copy-storage-all', '--copy-storage-inc'")); goto out; } @@ -10918,7 +10918,7 @@ doMigrate(void *opaque) g_autofree char **val = NULL; if (!(flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC))) { - vshError(ctl, "'--migrate-disks' requires one of '--copy-storage-all', '--copy-storage-inc'"); + vshError(ctl, "%s", _("'--migrate-disks' requires one of '--copy-storage-all', '--copy-storage-inc'")); goto out; } @@ -10939,7 +10939,7 @@ doMigrate(void *opaque) g_autofree char **val = NULL; if (!(flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC))) { - vshError(ctl, "'--migrate-disks-detect-zeroes' requires one of '--copy-storage-all', '--copy-storage-inc'"); + vshError(ctl, "%s", _("'--migrate-disks-detect-zeroes' requires one of '--copy-storage-all', '--copy-storage-inc'")); goto out; } diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 418bd995da..1b992e70f6 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -455,7 +455,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) if (rv == 0) { vshError(ctl, - "Could not get count of free %uKiB pages, no data returned", + _("Could not get count of free %1$uKiB pages, no data returned"), *pagesize); goto cleanup; } diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index e759b9f629..7ae6127513 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -129,7 +129,7 @@ vshFindNodeDevice(vshControl *ctl, const char *value) } if (!dev) { - vshError(ctl, "%s '%s'", _("Could not find matching device"), value); + vshError(ctl, _("Could not find matching device '%1$s'"), value); return NULL; } @@ -969,8 +969,8 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd) if (device_value) { if (!(dev = virNodeDeviceLookupByName(priv->conn, device_value))) { - vshError(ctl, "%s '%s'", - _("Could not find matching device"), device_value); + vshError(ctl, _("Could not find matching device '%1$s'"), + device_value); goto cleanup; } } diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 7c81c10845..3a4160107b 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -320,7 +320,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd) if (plain) { if (fwrite(value, 1, value_size, stdout) != value_size) { virSecureErase(value, value_size); - vshError(ctl, "failed to write secret"); + vshError(ctl, "%s", _("failed to write secret")); return false; } } else { diff --git a/tools/virsh.c b/tools/virsh.c index 6abae3dae9..090fdb2017 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -657,8 +657,8 @@ virshParseArgv(vshControl *ctl, int argc, char **argv) break; case 'd': if (virStrToLong_i(optarg, NULL, 10, &debug) < 0) { - vshError(ctl, _("option %1$s takes a numeric argument"), - longindex == -1 ? "-d" : "--debug"); + const char *optStr = longindex == -1 ? "-d" : "--debug"; + vshError(ctl, _("option %1$s takes a numeric argument"), optStr); exit(EXIT_FAILURE); } if (debug < VSH_ERR_DEBUG || debug > VSH_ERR_ERROR) diff --git a/tools/virt-admin.c b/tools/virt-admin.c index 16c9b2173a..fe2868d379 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1271,8 +1271,8 @@ vshAdmParseArgv(vshControl *ctl, int argc, char **argv) break; case 'd': if (virStrToLong_i(optarg, NULL, 10, &debug) < 0) { - vshError(ctl, _("option %1$s takes a numeric argument"), - longindex == -1 ? "-d" : "--debug"); + const char *optStr = longindex == -1 ? "-d" : "--debug"; + vshError(ctl, _("option %1$s takes a numeric argument"), optStr); exit(EXIT_FAILURE); } if (debug < VSH_ERR_DEBUG || debug > VSH_ERR_ERROR) diff --git a/tools/vsh.c b/tools/vsh.c index fb00cc40a6..fd6156ea76 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -280,34 +280,34 @@ vshCmddefCheckInternals(vshControl *ctl, const vshCmdDef *alias; if (!(alias = vshCmddefSearch(cmd->alias))) { - vshError(ctl, "command alias '%s' is pointing to a non-existent command '%s'", + vshError(ctl, _("command alias '%1$s' is pointing to a non-existent command '%2$s'"), cmd->name, cmd->alias); return -1; } if (alias->alias) { - vshError(ctl, "command alias '%s' is pointing to another command alias '%s'", + vshError(ctl, _("command alias '%1$s' is pointing to another command alias '%2$s'"), cmd->name, cmd->alias); return -1; } if (cmd->handler) { - vshError(ctl, "command '%s' has handler set", cmd->name); + vshError(ctl, _("command '%1$s' has handler set"), cmd->name); return -1; } if (cmd->opts) { - vshError(ctl, "command '%s' has options set", cmd->name); + vshError(ctl, _("command '%1$s' has options set"), cmd->name); return -1; } if (cmd->info) { - vshError(ctl, "command '%s' has info set", cmd->name); + vshError(ctl, _("command '%1$s' has info set"), cmd->name); return -1; } if (cmd->flags != 0) { - vshError(ctl, "command '%s' has multiple flags set", cmd->name); + vshError(ctl, _("command '%1$s' has multiple flags set"), cmd->name); return -1; } @@ -317,7 +317,7 @@ vshCmddefCheckInternals(vshControl *ctl, /* Each command has to provide a non-empty help string. */ if (!cmd->info || !cmd->info->help || !*cmd->info->help) { - vshError(ctl, "command '%s' lacks help", cmd->name); + vshError(ctl, _("command '%1$s' lacks help"), cmd->name); return -1; } @@ -348,7 +348,7 @@ vshCmddefCheckInternals(vshControl *ctl, /* allow at most one optional positional option */ if (opt->positional && !opt->required) { if (seenOptionalPositionalOption) { - vshError(ctl, "multiple optional positional arguments (%s, %s) of command '%s' are not allowed", + vshError(ctl, _("multiple optional positional arguments (%1$s, %2$s) of command '%3$s' are not allowed"), seenOptionalPositionalOption, opt->name, cmd->name); return -1; } @@ -358,45 +358,45 @@ vshCmddefCheckInternals(vshControl *ctl, /* all optional positional arguments must be defined after the required ones */ if (seenOptionalPositionalOption && opt->positional && opt->required) { - vshError(ctl, "required positional argument '%s' declared after an optional positional argument '%s' of command '%s'", + vshError(ctl, _("required positional argument '%1$s' declared after an optional positional argument '%2$s' of command '%3$s'"), opt->name, seenOptionalPositionalOption, cmd->name); return -1; } /* Mandate no completer flags if no completer is specified */ if (opt->completer_flags != 0 && !opt->completer) { - vshError(ctl, "completer_flags of argument '%s' of command '%s' must be 0 if no completer is used", + vshError(ctl, _("completer_flags of argument '%1$s' of command '%2$s' must be 0 if no completer is used"), opt->name, cmd->name); return -1; } if (opt->unwanted_positional && opt->positional) { - vshError(ctl, "unwanted_positional flag of argument '%s' of command '%s' must not be used together with positional", + vshError(ctl, _("unwanted_positional flag of argument '%1$s' of command '%2$s' must not be used together with positional"), opt->name, cmd->name); return -1; } switch (opt->type) { case VSH_OT_NONE: - vshError(ctl, "invalid type 'NONE' of option '%s' of command '%s'", + vshError(ctl, _("invalid type 'NONE' of option '%1$s' of command '%2$s'"), opt->name, cmd->name); return -1; case VSH_OT_BOOL: if (opt->completer) { - vshError(ctl, "bool parameter '%s' of command '%s' has completer set", + vshError(ctl, _("bool parameter '%1$s' of command '%2$s' has completer set"), opt->name, cmd->name); return -1; } if (opt->positional || opt->unwanted_positional) { - vshError(ctl, "boolean parameter '%s' of command '%s' must not be positional", + vshError(ctl, _("boolean parameter '%1$s' of command '%2$s' must not be positional"), opt->name, cmd->name); return -1; } if (opt->required) { - vshError(ctl, "parameter '%s' of command '%s' misused 'required' flag", + vshError(ctl, _("parameter '%1$s' of command '%2$s' misused 'required' flag"), opt->name, cmd->name); return -1; /* bool can't be mandatory */ } @@ -413,7 +413,7 @@ vshCmddefCheckInternals(vshControl *ctl, opt->unwanted_positional || opt->completer || !opt->help) { - vshError(ctl, "parameter '%s' of command '%s' has incorrect alias option", + vshError(ctl, _("parameter '%1$s' of command '%2$s' has incorrect alias option"), opt->name, cmd->name); return -1; } @@ -429,13 +429,13 @@ vshCmddefCheckInternals(vshControl *ctl, if (p) { /* If alias comes with value, replacement must not be bool */ if (cmd->opts[j].type == VSH_OT_BOOL) { - vshError(ctl, "alias '%s' of command '%s' has mismatched alias type", + vshError(ctl, _("alias '%1$s' of command '%2$s' has mismatched alias type"), opt->name, cmd->name); return -1; } } if (!cmd->opts[j].name) { - vshError(ctl, "alias '%s' of command '%s' has missing alias option", + vshError(ctl, _("alias '%1$s' of command '%2$s' has missing alias option"), opt->name, cmd->name); return -1; } @@ -444,7 +444,7 @@ vshCmddefCheckInternals(vshControl *ctl, case VSH_OT_ARGV: if (cmd->opts[i + 1].name) { - vshError(ctl, "parameter '%s' of command '%s' must be listed last", + vshError(ctl, _("parameter '%1$s' of command '%2$s' must be listed last"), opt->name, cmd->name); return -1; } @@ -453,7 +453,7 @@ vshCmddefCheckInternals(vshControl *ctl, case VSH_OT_INT: case VSH_OT_STRING: if (opt->positional && seenOptionalOption) { - vshError(ctl, "parameter '%s' of command '%s' must be listed before optional parameters", + vshError(ctl, _("parameter '%1$s' of command '%2$s' must be listed before optional parameters"), opt->name, cmd->name); return -1; } @@ -2424,9 +2424,13 @@ vshCloseLogFile(vshControl *ctl) { /* log file close */ if (VIR_CLOSE(ctl->log_fd) < 0) { - vshError(ctl, _("%1$s: failed to write log file: %2$s"), - ctl->logfile ? ctl->logfile : "?", - g_strerror(errno)); + if (ctl->logfile) { + vshError(ctl, _("%1$s: failed to write log file: %2$s"), + ctl->logfile, g_strerror(errno)); + } else { + vshError(ctl, _("failed to write log file: %1$s"), + g_strerror(errno)); + } } g_clear_pointer(&ctl->logfile, g_free); -- 2.48.1