diff --git a/ChangeLog b/ChangeLog index b05cc905a2..50e366b0e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Fri Jun 15 08:53:00 BST 2007 Richard W.M. Jones + + * src/internal.h, src/virsh.c: Replace _N with N_ so that + Solaris builds work (Mark Johnson). + * src/virsh.c: Add a couple of missing error messages (Mark + Johnson). + * python/types.c: Fix NULL pointer deref on DEBUG build + (Mark Johnson). + * src/virsh.c: Spelling fix (Mark Johnson). + Thu Jun 14 21:30:28 EST 2007 Daniel Berrange * libvirt.spec.in: Change way extra_release is inserted to diff --git a/python/types.c b/python/types.c index 4672e1c4df..cc0f2b171d 100644 --- a/python/types.c +++ b/python/types.c @@ -62,13 +62,13 @@ libvirt_charPtrWrap(char *str) { PyObject *ret; -#ifdef DEBUG - printf("libvirt_xmlcharPtrWrap: str = %s\n", str); -#endif if (str == NULL) { Py_INCREF(Py_None); return (Py_None); } +#ifdef DEBUG + printf("libvirt_xmlcharPtrWrap: str = %s\n", str); +#endif ret = PyString_FromString(str); free(str); return (ret); @@ -79,13 +79,13 @@ libvirt_constcharPtrWrap(const char *str) { PyObject *ret; -#ifdef DEBUG - printf("libvirt_xmlcharPtrWrap: str = %s\n", str); -#endif if (str == NULL) { Py_INCREF(Py_None); return (Py_None); } +#ifdef DEBUG + printf("libvirt_xmlcharPtrWrap: str = %s\n", str); +#endif ret = PyString_FromString(str); return (ret); } @@ -95,13 +95,13 @@ libvirt_charPtrConstWrap(const char *str) { PyObject *ret; -#ifdef DEBUG - printf("libvirt_xmlcharPtrWrap: str = %s\n", str); -#endif if (str == NULL) { Py_INCREF(Py_None); return (Py_None); } +#ifdef DEBUG + printf("libvirt_xmlcharPtrWrap: str = %s\n", str); +#endif ret = PyString_FromString(str); return (ret); } diff --git a/src/internal.h b/src/internal.h index 54c63421f7..20bf251a5e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -23,7 +23,7 @@ extern "C" { #endif #define _(str) dgettext(GETTEXT_PACKAGE, (str)) -#define _N(str) dgettext(GETTEXT_PACKAGE, (str)) +#define N_(str) dgettext(GETTEXT_PACKAGE, (str)) #define gettext_noop(str) (str) #ifdef __GNUC__ diff --git a/src/virsh.c b/src/virsh.c index 877ed3cc1b..ada4b0a9d1 100644 --- a/src/virsh.c +++ b/src/virsh.c @@ -324,7 +324,7 @@ cmdHelp(vshControl * ctl, vshCmd * cmd) vshPrint(ctl, _("Commands:\n\n")); for (def = commands; def->name; def++) vshPrint(ctl, " %-15s %s\n", def->name, - _N(vshCmddefGetInfo(def, "help"))); + N_(vshCmddefGetInfo(def, "help"))); return TRUE; } return vshCmddefHelp(ctl, cmdname, FALSE); @@ -581,7 +581,7 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED) if (virDomainGetInfo(dom, &info) < 0) state = _("no state"); else - state = _N(vshDomainStateToString(info.state)); + state = N_(vshDomainStateToString(info.state)); vshPrint(ctl, "%3d %-20s %s\n", virDomainGetID(dom), @@ -603,7 +603,7 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED) if (virDomainGetInfo(dom, &info) < 0) state = _("no state"); else - state = _N(vshDomainStateToString(info.state)); + state = N_(vshDomainStateToString(info.state)); vshPrint(ctl, "%3s %-20s %s\n", "-", names[i], state); @@ -647,7 +647,7 @@ cmdDomstate(vshControl * ctl, vshCmd * cmd) if (virDomainGetInfo(dom, &info) == 0) vshPrint(ctl, "%s\n", - _N(vshDomainStateToString(info.state))); + N_(vshDomainStateToString(info.state))); else ret = FALSE; @@ -705,7 +705,7 @@ static vshCmdInfo info_create[] = { }; static vshCmdOptDef opts_create[] = { - {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file conatining an XML domain description")}, + {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing an XML domain description")}, {NULL, 0, 0, NULL} }; @@ -1383,7 +1383,7 @@ cmdDominfo(vshControl * ctl, vshCmd * cmd) if (virDomainGetInfo(dom, &info) == 0) { vshPrint(ctl, "%-15s %s\n", _("State:"), - _N(vshDomainStateToString(info.state))); + N_(vshDomainStateToString(info.state))); vshPrint(ctl, "%-15s %d\n", _("CPU(s):"), info.nrVirtCpu); @@ -1469,7 +1469,7 @@ cmdVcpuinfo(vshControl * ctl, vshCmd * cmd) vshPrint(ctl, "%-15s %d\n", _("VCPU:"), n); vshPrint(ctl, "%-15s %d\n", _("CPU:"), cpuinfo[n].cpu); vshPrint(ctl, "%-15s %s\n", _("State:"), - _N(vshDomainVcpuStateToString(cpuinfo[n].state))); + N_(vshDomainVcpuStateToString(cpuinfo[n].state))); if (cpuinfo[n].cpuTime != 0) { double cpuUsed = cpuinfo[n].cpuTime; @@ -1487,6 +1487,10 @@ cmdVcpuinfo(vshControl * ctl, vshCmd * cmd) } } } else { + if (info.state == VIR_DOMAIN_SHUTOFF) { + vshError(ctl, FALSE, + _("Domain shut off, virtual CPUs not present.")); + } ret = FALSE; } @@ -1618,6 +1622,7 @@ cmdSetvcpus(vshControl * ctl, vshCmd * cmd) count = vshCommandOptInt(cmd, "count", &count); if (!count) { + vshError(ctl, FALSE, _("Invalid number of virtual CPUs.")); virDomainFree(dom); return FALSE; } @@ -1629,7 +1634,7 @@ cmdSetvcpus(vshControl * ctl, vshCmd * cmd) } if (count > maxcpu) { - vshError(ctl, FALSE, _("Too many virtual CPU's.")); + vshError(ctl, FALSE, _("Too many virtual CPUs.")); virDomainFree(dom); return FALSE; } @@ -2865,8 +2870,8 @@ vshCmddefHelp(vshControl * ctl, const char *cmdname, int withprog) return FALSE; } else { vshCmdOptDef *opt; - const char *desc = _N(vshCmddefGetInfo(def, "desc")); - const char *help = _N(vshCmddefGetInfo(def, "help")); + const char *desc = N_(vshCmddefGetInfo(def, "desc")); + const char *help = N_(vshCmddefGetInfo(def, "help")); const char *syntax = vshCmddefGetInfo(def, "syntax"); fputs(_(" NAME\n"), stdout); @@ -2897,7 +2902,7 @@ vshCmddefHelp(vshControl * ctl, const char *cmdname, int withprog) else if (opt->type == VSH_OT_DATA) snprintf(buf, sizeof(buf), "<%s>", opt->name); - fprintf(stdout, " %-15s %s\n", buf, _N(opt->help)); + fprintf(stdout, " %-15s %s\n", buf, N_(opt->help)); } } fputc('\n', stdout); @@ -3803,7 +3808,7 @@ vshUsage(vshControl * ctl, const char *cmdname) for (cmd = commands; cmd->name; cmd++) fprintf(stdout, - " %-15s %s\n", cmd->name, _N(vshCmddefGetInfo(cmd, + " %-15s %s\n", cmd->name, N_(vshCmddefGetInfo(cmd, "help"))); fprintf(stdout,