* src/util.h (to_uchar): Define function.
* src/nodeinfo.c (linuxNodeInfoCPUPopulate): Apply to_uchar to is* operand.
* src/qemu_driver.c (qemudExtractMonitorPath): Likewise.
* src/sexpr.c (_string2sexpr): Likewise.
* src/stats_linux.c (xenLinuxDomainDeviceID): Likewise.
* src/util.c (TOLOWER, __virMacAddrCompare, virParseMacAddr): Likewise.
* src/virsh.c (cmdVcpupin, vshCommandGetToken): Likewise.
+Fri Apr 25 16:51:58 CEST 2008 Jim Meyering <meyering@redhat.com>
+
+ avoid problems with sign-extended "char" operand to is* functions
+ * src/util.h (to_uchar): Define function.
+ * src/sexpr.c (_string2sexpr): Apply to_uchar to is* operand.
+ * src/nodeinfo.c (linuxNodeInfoCPUPopulate): Likewise.
+ * src/qemu_driver.c (qemudExtractMonitorPath): Likewise.
+ * src/stats_linux.c (xenLinuxDomainDeviceID): Likewise.
+ * src/util.c (TOLOWER, __virMacAddrCompare, virParseMacAddr): Likewise.
+ * src/virsh.c (cmdVcpupin, vshCommandGetToken): Likewise.
+
Thu Apr 24 17:18:18 CEST 2008 Daniel Veillard <veillard@redhat.com>
* docs/page.xsl docs/redhat.gif docs/*.html: using the shadowman
/*
* nodeinfo.c: Helper routines for OS specific node information
*
- * Copyright (C) 2006, 2007 Red Hat, Inc.
+ * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
char *buf = line;
if (STREQLEN(buf, "processor", 9)) { /* aka a single logical CPU */
buf += 9;
- while (*buf && isspace(*buf))
+ while (*buf && isspace(to_uchar(*buf)))
buf++;
if (*buf != ':') {
__virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR,
char *p;
unsigned int ui;
buf += 9;
- while (*buf && isspace(*buf))
+ while (*buf && isspace(to_uchar(*buf)))
buf++;
if (*buf != ':' || !buf[1]) {
__virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR,
}
if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0
/* Accept trailing fractional part. */
- && (*p == '\0' || *p == '.' || isspace(*p)))
+ && (*p == '\0' || *p == '.' || isspace(to_uchar(*p))))
nodeinfo->mhz = ui;
} else if (STREQLEN(buf, "cpu cores", 9)) { /* aka cores */
char *p;
unsigned int id;
buf += 9;
- while (*buf && isspace(*buf))
+ while (*buf && isspace(to_uchar(*buf)))
buf++;
if (*buf != ':' || !buf[1]) {
__virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR,
return -1;
}
if (virStrToLong_ui(buf+1, &p, 10, &id) == 0
- && (*p == '\0' || isspace(*p))
+ && (*p == '\0' || isspace(to_uchar(*p)))
&& id > nodeinfo->cores)
nodeinfo->cores = id;
}
* The monitor path ends at first whitespace char
* so lets search for it & NULL terminate it there
*/
- if (isspace(*path)) {
+ if (isspace(to_uchar(*path))) {
*path = '\0';
return 0;
}
#include "internal.h"
#include "sexpr.h"
+#include "util.h"
/**
* virSexprError:
} else {
start = ptr;
- while (*ptr && !isspace(*ptr) && *ptr != ')' && *ptr != '(') {
+ while (*ptr && !isspace(to_uchar(*ptr))
+ && *ptr != ')' && *ptr != '(') {
ptr++;
}
/*
* Linux block and network stats.
*
- * Copyright (C) 2007 Red Hat, Inc.
+ * Copyright (C) 2007, 2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
}
if (path[4] != '\0') {
- if (!isdigit(path[4]) || path[4] == '0' ||
+ if (!isdigit(to_uchar(path[4])) || path[4] == '0' ||
virStrToLong_i(path+4, NULL, 10, &part) < 0 ||
part < 1 || part > 15) {
statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
} else {
p = path + 3;
}
- if (p && (!isdigit(*p) || *p == '0' ||
+ if (p && (!isdigit(to_uchar(*p)) || *p == '0' ||
virStrToLong_i(p, NULL, 10, &part) < 0 ||
part < 1 || part > 15)) {
statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
}
if (path[3] != '\0') {
- if (!isdigit(path[3]) || path[3] == '0' ||
+ if (!isdigit(to_uchar(path[3])) || path[3] == '0' ||
virStrToLong_i(path+3, NULL, 10, &part) < 0 ||
part < 1 || part > 63) {
statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
#define MAX_ERROR_LEN 1024
-#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
+#define TOLOWER(Ch) (isupper (to_uchar(Ch)) ? tolower (Ch) : (Ch))
#define virLog(msg...) fprintf(stderr, msg)
{
unsigned char c, d;
do {
- while (*p == '0' && isxdigit (p[1]))
+ while (*p == '0' && isxdigit (to_uchar(p[1])))
++p;
- while (*q == '0' && isxdigit (q[1]))
+ while (*q == '0' && isxdigit (to_uchar(q[1])))
++q;
c = TOLOWER (*p);
d = TOLOWER (*q);
/* This is solely to avoid accepting the leading
* space or "+" that strtoul would otherwise accept.
*/
- if (!isxdigit(*str))
+ if (!isxdigit(to_uchar(*str)))
break;
result = strtoul(str, &end_ptr, 16);
#include "internal.h"
#include "util-lib.h"
+/* Convert a possibly-signed character to an unsigned character. This is
+ a bit safer than casting to unsigned char, since it catches some type
+ errors that the cast doesn't. */
+static inline unsigned char to_uchar (char ch) { return ch; }
+
int virExec(virConnectPtr conn, char **argv, int *retpid,
int infd, int *outfd, int *errfd);
int virExecNonBlock(virConnectPtr conn, char **argv, int *retpid,
for (i = 0; cpulist[i]; i++) {
switch (state) {
case expect_num:
- if (!isdigit (cpulist[i])) {
+ if (!isdigit (to_uchar(cpulist[i]))) {
vshError( ctl, FALSE, _("cpulist: %s: Invalid format. Expecting digit at position %d (near '%c')."), cpulist, i, cpulist[i]);
virDomainFree (dom);
return FALSE;
case expect_num_or_comma:
if (cpulist[i] == ',')
state = expect_num;
- else if (!isdigit (cpulist[i])) {
+ else if (!isdigit (to_uchar(cpulist[i]))) {
vshError(ctl, FALSE, _("cpulist: %s: Invalid format. Expecting digit or comma at position %d (near '%c')."), cpulist, i, cpulist[i]);
virDomainFree (dom);
return FALSE;
if (tk == VSH_TK_NONE) {
if (*p == '-' && *(p + 1) == '-' && *(p + 2)
- && isalnum((unsigned char) *(p + 2))) {
+ && isalnum(to_uchar(*(p + 2)))) {
tk = VSH_TK_OPTION;
p += 2;
} else {