|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num
# HG changeset patch
# User Olaf Hering <olaf@xxxxxxxxx>
# Date 1333046226 -7200
# Node ID 1c86e2e5268d14587c736e3f575d0aa42869de83
# Parent 4bd752a4cdf323c41c50f8cd6286f566d67adeae
tools/blktap: fix access errors in convert_dev_name_to_num
xs_api.c: In function 'convert_dev_name_to_num':
xs_api.c:227:4: warning: value computed is not used [-Wunused-value]
xs_api.c:229:3: warning: value computed is not used [-Wunused-value]
xs_api.c:235:4: warning: value computed is not used [-Wunused-value]
xs_api.c:237:3: warning: value computed is not used [-Wunused-value]
xs_api.c:244:4: warning: value computed is not used [-Wunused-value]
xs_api.c:246:3: warning: value computed is not used [-Wunused-value]
ptr should be increased in each iteration, not the char it points to.
At the end p should be increased as well to get to the number, not the
char it points to.
Luckily, the function can not be called from ueblktap_setup() due to a
logic eror.
Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
diff -r 4bd752a4cdf3 -r 1c86e2e5268d tools/blktap/lib/xs_api.c
--- a/tools/blktap/lib/xs_api.c
+++ b/tools/blktap/lib/xs_api.c
@@ -210,40 +210,41 @@ done:
}
int convert_dev_name_to_num(char *name) {
- char *p, *ptr;
+ char *p;
+ const char *ptr;
int majors[10] = {3,22,33,34,56,57,88,89,90,91};
int maj,i,ret = 0;
- char *p_sd = "/dev/sd";
- char *p_hd = "/dev/hd";
- char *p_xvd = "/dev/xvd";
- char *p_plx = "plx";
- char *alpha = "abcdefghijklmnop";
+ static const char p_sd[] = "/dev/sd";
+ static const char p_hd[] = "/dev/hd";
+ static const char p_xvd[] = "/dev/xvd";
+ static const char p_plx[] = "plx";
+ static const char alpha[] = "abcdefghijklmnop";
if (strstr(name, p_sd) != NULL) {
p = name + strlen(p_sd);
for(i = 0, ptr = alpha; i < strlen(alpha); i++) {
if(*ptr == *p)
break;
- *ptr++;
+ ptr++;
}
- *p++;
+ p++;
ret = BASE_DEV_VAL + (16*i) + atoi(p);
} else if (strstr(name, p_hd) != NULL) {
p = name + strlen(p_hd);
for (i = 0, ptr = alpha; i < strlen(alpha); i++) {
if(*ptr == *p) break;
- *ptr++;
+ ptr++;
}
- *p++;
+ p++;
ret = (majors[i/2]*256) + atoi(p);
} else if (strstr(name, p_xvd) != NULL) {
p = name + strlen(p_xvd);
for(i = 0, ptr = alpha; i < strlen(alpha); i++) {
if(*ptr == *p) break;
- *ptr++;
+ ptr++;
}
- *p++;
+ p++;
ret = (202*256) + (16*i) + atoi(p);
} else if (strstr(name, p_plx) != NULL) {
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |