Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 00 of 18] tools: fix bugs and build errors triggered by -O2 -Wall -Werror
Changes: tools/blktap: fix access errors in convert_dev_name_to_num tools/blktap: fix params and physical-device parsing tools/blktap: fix access error in img2qcow.c tools/blktap: fix access error in qcow2raw.c tools/blktap2: fix build errors caused by Werror in vhd_journal_write_entry tools/blktap2: fix out of bounds access in block-log.c tools/blktap2: fix build errors caused by Werror in tdqcow_get_parent_id tools/blktap2: fix access error in img2qcow.c tools/blktap2: fix access error in qcow2raw.c tools/libvchan: fix build errors caused by -Werror in node-select.c tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback tools/memshr: fix build errors caused by Werror tools/xenpaging: fix build errors caused by -Werror tools/libvchan: fix build errors caused by Werror in io.c tools/blktap2: remove static string table from header file tools/blktap2: fix build errors caused by Werror, remove blkif_op_name tools/blktap2: remove unused labels tools/blktap2: fix build errors caused by Werror, remove unused variables tools/blktap/drivers/img2qcow.c | 2 +- tools/blktap/drivers/qcow2raw.c | 2 +- tools/blktap/lib/xenbus.c | 25 ++++++++++++------------- tools/blktap/lib/xs_api.c | 25 +++++++++++++------------ tools/blktap2/control/tap-ctl-check.c | 1 - tools/blktap2/control/tap-ctl-list.c | 3 --- tools/blktap2/control/tap-ctl-spawn.c | 2 +- tools/blktap2/drivers/block-aio.c | 3 --- tools/blktap2/drivers/block-log.c | 10 ++++------ tools/blktap2/drivers/block-qcow.c | 20 +++++++------------- tools/blktap2/drivers/block-ram.c | 7 ------- tools/blktap2/drivers/block-remus.c | 16 ++-------------- tools/blktap2/drivers/block-vhd.c | 24 +----------------------- tools/blktap2/drivers/img2qcow.c | 2 +- tools/blktap2/drivers/io-optimize.c | 1 - tools/blktap2/drivers/qcow2raw.c | 2 +- tools/blktap2/drivers/tapdisk-client.c | 1 - tools/blktap2/drivers/tapdisk-control.c | 9 ++------- tools/blktap2/drivers/tapdisk-filter.c | 2 +- tools/blktap2/drivers/tapdisk-interface.c | 1 - tools/blktap2/drivers/tapdisk-queue.c | 3 +-- tools/blktap2/drivers/tapdisk-server.c | 1 - tools/blktap2/drivers/tapdisk-utils.c | 1 - tools/blktap2/drivers/tapdisk-vbd.c | 5 +---- tools/blktap2/drivers/td.c | 2 +- tools/blktap2/include/blktaplib.h | 11 ----------- tools/blktap2/include/vhd.h | 11 ----------- tools/blktap2/lvm/lvm-util.c | 2 +- tools/blktap2/vhd/lib/libvhd-journal.c | 14 ++------------ tools/blktap2/vhd/lib/libvhd.c | 6 ++---- tools/blktap2/vhd/lib/vhd-util-check.c | 2 -- tools/blktap2/vhd/lib/vhd-util-read.c | 16 +++++++++++++--- tools/blktap2/vhd/lib/vhd-util-resize.c | 2 +- tools/blktap2/vhd/lib/vhd-util-scan.c | 5 +---- tools/blktap2/vhd/lib/vhd-util-set-field.c | 2 -- tools/libvchan/io.c | 4 ++-- tools/libvchan/node-select.c | 14 ++++++++++---- tools/libxl/libxl.c | 2 +- tools/memshr/bidir-hash.h | 8 ++++---- tools/memshr/interface.c | 3 --- tools/xenpaging/xenpaging.c | 5 ----- 41 files changed, 87 insertions(+), 190 deletions(-)
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # 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@aepfle.de> 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) {
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 02 of 18] tools/blktap: fix params and physical-device parsing
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046227 -7200 # Node ID 5c77f79cc3064b575c1da2b8fb28eec53dd8bfdc # Parent 1c86e2e5268d14587c736e3f575d0aa42869de83 tools/blktap: fix params and physical-device parsing If parsing the "physical-device" property fails the physical device node should come from the "params" property. But since the deverr value was overwritten during read of the "mode" property, the "params" property was never parsed. Fix this by reading "mode" before "physical-device" so that deverr can be reused to check the "params" property. Simplify ->pdev assignment. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 1c86e2e5268d -r 5c77f79cc306 tools/blktap/lib/xenbus.c --- a/tools/blktap/lib/xenbus.c +++ b/tools/blktap/lib/xenbus.c @@ -335,6 +335,15 @@ static void ueblktap_setup(struct xs_han goto fail; } + /* Check to see if device is to be opened read-only. */ + deverr = xs_gather(h, bepath, "mode", NULL, &path, NULL); + if (deverr) { + DPRINTF("ERROR: could not find read/write mode\n"); + goto fail; + } else if (path[0] == ''r'') + be->readonly = 1; + + /* deverr reused later during params parsing */ deverr = xs_gather(h, bepath, "physical-device", "%li", &pdev, NULL); if (!deverr) { DPRINTF("pdev set to %ld\n",pdev); @@ -345,14 +354,6 @@ static void ueblktap_setup(struct xs_han be->pdev = pdev; } - /* Check to see if device is to be opened read-only. */ - deverr = xs_gather(h, bepath, "mode", NULL, &path, NULL); - if (deverr) { - DPRINTF("ERROR: could not find read/write mode\n"); - goto fail; - } else if (path[0] == ''r'') - be->readonly = 1; - if (be->blkif == NULL) { /* Front end dir is a number, which is used as the handle. */ p = strrchr(be->frontpath, ''/'') + 1; @@ -375,11 +376,9 @@ static void ueblktap_setup(struct xs_han goto fail; be->blkif->info = blk; - if (deverr) { - /*Dev number was not available, try to set manually*/ - pdev = convert_dev_name_to_num(blk->params); - be->pdev = pdev; - } + /*Dev number was not available, try to set manually*/ + if (deverr) + be->pdev = convert_dev_name_to_num(blk->params); if (check_image(h, be, &errmsg)) goto fail;
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 03 of 18] tools/blktap: fix access error in img2qcow.c
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046228 -7200 # Node ID 526135e426fa80dfd58c272b41cd3f4ab39c62d6 # Parent 5c77f79cc3064b575c1da2b8fb28eec53dd8bfdc tools/blktap: fix access error in img2qcow.c img2qcow.c: In function ''print_bytes'': img2qcow.c:72:9: warning: value computed is not used [-Wunused-value] Increment the pointer, not the char it points to. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 5c77f79cc306 -r 526135e426fa tools/blktap/drivers/img2qcow.c --- a/tools/blktap/drivers/img2qcow.c +++ b/tools/blktap/drivers/img2qcow.c @@ -69,7 +69,7 @@ static void print_bytes(void *ptr, int l DFPRINTF("Buf dump, length %d:\n",length); for (k = 0; k < length; k++) { DFPRINTF("%x",*p); - *p++; + p++; if(k % 16 == 0) DFPRINTF("\n"); else if(k % 2 == 0) DFPRINTF(" "); }
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 04 of 18] tools/blktap: fix access error in qcow2raw.c
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046229 -7200 # Node ID 9abe0baa60fb8773707118856c300c1dd478aaf2 # Parent 526135e426fa80dfd58c272b41cd3f4ab39c62d6 tools/blktap: fix access error in qcow2raw.c qcow2raw.c: In function ''print_bytes'': qcow2raw.c:76:9: warning: value computed is not used [-Wunused-value] Increment the pointer, not the char it points to. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 526135e426fa -r 9abe0baa60fb tools/blktap/drivers/qcow2raw.c --- a/tools/blktap/drivers/qcow2raw.c +++ b/tools/blktap/drivers/qcow2raw.c @@ -73,7 +73,7 @@ static void print_bytes(void *ptr, int l DFPRINTF("Buf dump, length %d:\n",length); for (k = 0; k < length; k++) { DFPRINTF("%x",*p); - *p++; + p++; if (k % 16 == 0) DFPRINTF("\n"); else if (k % 2 == 0) DFPRINTF(" "); }
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 05 of 18] tools/blktap2: fix build errors caused by Werror in vhd_journal_write_entry
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046230 -7200 # Node ID 91286869cde3e05f3eff1b1a7f8bea9d11452792 # Parent 9abe0baa60fb8773707118856c300c1dd478aaf2 tools/blktap2: fix build errors caused by Werror in vhd_journal_write_entry -O2 -Wall -Werror triggers these warnings: libvhd-journal.c: In function ''vhd_journal_write_entry'': libvhd-journal.c:335: warning: statement with no effect Really return the error from vhd_journal_write() to caller. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 9abe0baa60fb -r 91286869cde3 tools/blktap2/vhd/lib/libvhd-journal.c --- a/tools/blktap2/vhd/lib/libvhd-journal.c +++ b/tools/blktap2/vhd/lib/libvhd-journal.c @@ -330,11 +330,7 @@ vhd_journal_write_entry(vhd_journal_t *j memcpy(&e, entry, sizeof(vhd_journal_entry_t)); vhd_journal_entry_out(&e); - err = vhd_journal_write(j, &e, sizeof(vhd_journal_entry_t)); - if (err) - err; - - return 0; + return vhd_journal_write(j, &e, sizeof(vhd_journal_entry_t)); } static int
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 06 of 18] tools/blktap2: fix out of bounds access in block-log.c
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046231 -7200 # Node ID 51c773447549ec98a5bd37739b9d87dc28b365c2 # Parent 91286869cde3e05f3eff1b1a7f8bea9d11452792 tools/blktap2: fix out of bounds access in block-log.c block-log.c: In function ''ctl_close_sock'': block-log.c:363:23: warning: array subscript is above array bounds [-Warray-bounds] Adjust loop condition in ctl_close_sock() to fix warning. Adjust array acccess in ctl_close() to actually access the array member. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 91286869cde3 -r 51c773447549 tools/blktap2/drivers/block-log.c --- a/tools/blktap2/drivers/block-log.c +++ b/tools/blktap2/drivers/block-log.c @@ -324,11 +324,11 @@ static int ctl_open(struct tdlog_state* static int ctl_close(struct tdlog_state* s) { while (s->connected) { + s->connected--; tapdisk_server_unregister_event(s->connections[s->connected].id); close(s->connections[s->connected].fd); s->connections[s->connected].fd = -1; s->connections[s->connected].id = 0; - s->connected--; } if (s->ctl.fd >= 0) { @@ -359,7 +359,7 @@ static int ctl_close_sock(struct tdlog_s { int i; - for (i = 0; i <= s->connected; i++) { + for (i = 0; i < s->connected; i++) { if (s->connections[i].fd == fd) { tapdisk_server_unregister_event(s->connections[i].id); close(s->connections[i].fd);
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 07 of 18] tools/blktap2: fix build errors caused by Werror in tdqcow_get_parent_id
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046235 -7200 # Node ID 16f6fc42abaa781e52aa99cac5e197dee7a79098 # Parent 51c773447549ec98a5bd37739b9d87dc28b365c2 tools/blktap2: fix build errors caused by Werror in tdqcow_get_parent_id -O2 -Wall -Werror triggers these warnings: block-qcow.c: In function ''tdqcow_get_parent_id'': block-qcow.c:1457:17: warning: ''type'' may be used uninitialized in this function [-Wuninitialized] The compiler can not know that open() writes to errno so it has to assume that errno can be zero. Since tdqcow_get_image_type() has just one caller which expects a bool as return type, adjust return codes so that the compiler knows when ''type'' is initialised. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 51c773447549 -r 16f6fc42abaa tools/blktap2/drivers/block-qcow.c --- a/tools/blktap2/drivers/block-qcow.c +++ b/tools/blktap2/drivers/block-qcow.c @@ -1408,12 +1408,12 @@ tdqcow_get_image_type(const char *file, fd = open(file, O_RDONLY); if (fd == -1) - return -errno; + return -1; size = read(fd, &header, sizeof(header)); close(fd); if (size != sizeof(header)) - return (errno ? -errno : -EIO); + return -1; be32_to_cpus(&header.magic); if (header.magic == QCOW_MAGIC)
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 08 of 18] tools/blktap2: fix access error in img2qcow.c
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046316 -7200 # Node ID d751f4ddacf52f027c66394cd5ac5233b83943be # Parent 16f6fc42abaa781e52aa99cac5e197dee7a79098 tools/blktap2: fix access error in img2qcow.c img2qcow.c: In function ''print_bytes'': img2qcow.c:90:9: warning: value computed is not used [-Wunused-value] Increment the pointer, not the char it points to. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 16f6fc42abaa -r d751f4ddacf5 tools/blktap2/drivers/img2qcow.c --- a/tools/blktap2/drivers/img2qcow.c +++ b/tools/blktap2/drivers/img2qcow.c @@ -87,7 +87,7 @@ static void print_bytes(void *ptr, int l DFPRINTF("Buf dump, length %d:\n",length); for (k = 0; k < length; k++) { DFPRINTF("%x",*p); - *p++; + p++; if(k % 16 == 0) DFPRINTF("\n"); else if(k % 2 == 0) DFPRINTF(" "); }
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 09 of 18] tools/blktap2: fix access error in qcow2raw.c
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046378 -7200 # Node ID ee47e3c3324cc97c90df81ffd60941d61a15c4ae # Parent d751f4ddacf52f027c66394cd5ac5233b83943be tools/blktap2: fix access error in qcow2raw.c qcow2raw.c: In function ''print_bytes'': qcow2raw.c:96:9: warning: value computed is not used [-Wunused-value] Increment the pointer, not the char it points to. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r d751f4ddacf5 -r ee47e3c3324c tools/blktap2/drivers/qcow2raw.c --- a/tools/blktap2/drivers/qcow2raw.c +++ b/tools/blktap2/drivers/qcow2raw.c @@ -93,7 +93,7 @@ static void print_bytes(void *ptr, int l DFPRINTF("Buf dump, length %d:\n",length); for (k = 0; k < length; k++) { DFPRINTF("%x",*p); - *p++; + p++; if (k % 16 == 0) DFPRINTF("\n"); else if (k % 2 == 0) DFPRINTF(" "); }
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046730 -7200 # Node ID 1092e073b88e0aed775eec6d7349f310229e9aed # Parent ee47e3c3324cc97c90df81ffd60941d61a15c4ae tools/libvchan: fix build errors caused by -Werror in node-select.c -O2 -Wall -Werror triggers these warnings: node-select.c:57:6: warning: function declaration isn''t a prototype [-Wstrict-prototypes] node-select.c: In function ''vchan_wr'': node-select.c:60:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] node-select.c: At top level: node-select.c:71:6: warning: function declaration isn''t a prototype [-Wstrict-prototypes] node-select.c: In function ''stdout_wr'': node-select.c:74:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r ee47e3c3324c -r 1092e073b88e tools/libvchan/node-select.c --- a/tools/libvchan/node-select.c +++ b/tools/libvchan/node-select.c @@ -54,10 +54,13 @@ int insiz = 0; int outsiz = 0; struct libxenvchan *ctrl = 0; -void vchan_wr() { +void vchan_wr(void) +{ + int ret; + if (!insiz) return; - int ret = libxenvchan_write(ctrl, inbuf, insiz); + ret = libxenvchan_write(ctrl, inbuf, insiz); if (ret < 0) { fprintf(stderr, "vchan write failed\n"); exit(1); @@ -68,10 +71,13 @@ void vchan_wr() { } } -void stdout_wr() { +void stdout_wr(void) +{ + int ret; + if (!outsiz) return; - int ret = write(1, outbuf, outsiz); + ret = write(1, outbuf, outsiz); if (ret < 0 && errno != EAGAIN) exit(1); if (ret > 0) {
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046733 -7200 # Node ID 46ec38b96a225eadcadd70927eb2b136f1172265 # Parent 1092e073b88e0aed775eec6d7349f310229e9aed tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback -O2 -Wall -Werror triggers these warnings: libxl.c: In function ''disk_eject_xswatch_callback'': libxl.c:928: warning: zero-length printf format string Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 1092e073b88e -r 46ec38b96a22 tools/libxl/libxl.c --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -925,7 +925,7 @@ static void disk_eject_xswatch_callback( if (!value || strcmp(value, "eject")) return; - if (libxl__xs_write(gc, XBT_NULL, wpath, "")) { + if (libxl__xs_write(gc, XBT_NULL, wpath, "%s", "")) { LIBXL__EVENT_DISASTER(egc, "xs_write failed acknowledging eject", errno, LIBXL_EVENT_TYPE_DISK_EJECT); return;
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 12 of 18] tools/memshr: fix build errors caused by Werror
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046764 -7200 # Node ID 95ab84b43c99e4c9a82cd42aca0e021a091741b4 # Parent 46ec38b96a225eadcadd70927eb2b136f1172265 tools/memshr: fix build errors caused by Werror -O2 -Wall -Werror triggers these warnings: cc1: warnings being treated as errors interface.c: In function ''memshr_daemon_initialize'': interface.c:55: error: unused variable ''h'' interface.c:54: error: unused variable ''shm_base_addr'' cc1: warnings being treated as errors bidir-hash.h:47: error: ''fgprtshr_fgprt_hash'' defined but not used bidir-hash.h:52: error: ''fgprtshr_mfn_hash'' defined but not used bidir-hash.h:57: error: ''fgprtshr_fgprt_cmp'' defined but not used bidir-hash.h:62: error: ''fgprtshr_mfn_cmp'' defined but not used make[3]: *** [interface.o] Error 1 make[3]: *** [bidir-daemon.o] Error 1 cc1: warnings being treated as errors bidir-hash.h:47: error: ''fgprtshr_fgprt_hash'' defined but not used bidir-hash.h:52: error: ''fgprtshr_mfn_hash'' defined but not used bidir-hash.h:57: error: ''fgprtshr_fgprt_cmp'' defined but not used bidir-hash.h:62: error: ''fgprtshr_mfn_cmp'' defined but not used Mark fingerprint functions as inline, remove unused variables. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 46ec38b96a22 -r 95ab84b43c99 tools/memshr/bidir-hash.h --- a/tools/memshr/bidir-hash.h +++ b/tools/memshr/bidir-hash.h @@ -43,22 +43,22 @@ typedef struct vbdblk { #undef BIDIR_VALUE #undef BIDIR_KEY_T #undef BIDIR_VALUE_T -static uint32_t fgprtshr_fgprt_hash(uint32_t h) +static inline uint32_t fgprtshr_fgprt_hash(uint32_t h) { return h; } -static uint32_t fgprtshr_mfn_hash(uint64_t m) +static inline uint32_t fgprtshr_mfn_hash(uint64_t m) { return (uint32_t)m; } -static int fgprtshr_fgprt_cmp(uint32_t h1, uint32_t h2) +static inline int fgprtshr_fgprt_cmp(uint32_t h1, uint32_t h2) { return (h1 == h2); } -static int fgprtshr_mfn_cmp(uint32_t m1, uint32_t m2) +static inline int fgprtshr_mfn_cmp(uint32_t m1, uint32_t m2) { return (m1 == m2); } diff -r 46ec38b96a22 -r 95ab84b43c99 tools/memshr/interface.c --- a/tools/memshr/interface.c +++ b/tools/memshr/interface.c @@ -51,9 +51,6 @@ void memshr_set_domid(int domid) void memshr_daemon_initialize(void) { - void *shm_base_addr; - struct fgprtshr_hash *h; - memset(&memshr, 0, sizeof(private_memshr_info_t)); if((SHARED_INFO = shm_shared_info_open(1)) == NULL)
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 13 of 18] tools/xenpaging: fix build errors caused by -Werror
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046782 -7200 # Node ID bd4bb152538c54457026d3bee6f8b9dba1021b7f # Parent 95ab84b43c99e4c9a82cd42aca0e021a091741b4 tools/xenpaging: fix build errors caused by -Werror -O2 -Wall -Werror triggers these warnings: xenpaging.c: In function ''xenpaging_init'': xenpaging.c:284: warning: unused variable ''p'' xenpaging.c: In function ''xenpaging_evict_page'': xenpaging.c:606: warning: unused variable ''domctl'' xenpaging.c: In function ''resume_pages'': xenpaging.c:742: warning: unused variable ''xch'' xenpaging.c: In function ''evict_pages'': xenpaging.c:820: warning: unused variable ''xch'' Remove the offending local variables. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 95ab84b43c99 -r bd4bb152538c tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c +++ b/tools/xenpaging/xenpaging.c @@ -279,7 +279,6 @@ static struct xenpaging *xenpaging_init( xc_domaininfo_t domain_info; xc_interface *xch = NULL; xentoollog_logger *dbg = NULL; - char *p; int rc; unsigned long ring_pfn, mmap_pfn; @@ -601,8 +600,6 @@ static int xenpaging_evict_page(struct x xen_pfn_t victim = gfn; int ret; - DECLARE_DOMCTL; - /* Nominate page */ ret = xc_mem_paging_nominate(xch, paging->mem_event.domain_id, gfn); if ( ret < 0 ) @@ -737,7 +734,6 @@ static int xenpaging_populate_page(struc /* Trigger a page-in for a batch of pages */ static void resume_pages(struct xenpaging *paging, int num_pages) { - xc_interface *xch = paging->xc_handle; int i, num = 0; for ( i = 0; i < paging->max_pages && num < num_pages; i++ ) @@ -815,7 +811,6 @@ static int evict_victim(struct xenpaging */ static int evict_pages(struct xenpaging *paging, int num_pages) { - xc_interface *xch = paging->xc_handle; int rc, slot, num = 0; /* Reuse known free slots */
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 14 of 18] tools/libvchan: fix build errors caused by Werror in io.c
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046863 -7200 # Node ID 0966600a98f1b3a4707fa3bfae24d207d424c452 # Parent bd4bb152538c54457026d3bee6f8b9dba1021b7f tools/libvchan: fix build errors caused by Werror in io.c -O2 -Wall -Werror triggers these warnings: io.c: In function ''do_send'': io.c:196: warning: ignoring return value of ''writev'', declared with attribute warn_unused_result io.c: In function ''do_recv'': io.c:287: warning: ignoring return value of ''writev'', declared with attribute warn_unused_result writev to -1 will always fail, silence the warning. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r bd4bb152538c -r 0966600a98f1 tools/libvchan/io.c --- a/tools/libvchan/io.c +++ b/tools/libvchan/io.c @@ -193,7 +193,7 @@ static int do_send(struct libxenvchan *c iov[0].iov_len = snprintf(metainfo, 32, "vchan@%p wr", ctrl); iov[1].iov_base = (void *)data; iov[1].iov_len = size; - writev(-1, iov, 2); + if (writev(-1, iov, 2)); } if (avail_contig > size) avail_contig = size; @@ -284,7 +284,7 @@ static int do_recv(struct libxenvchan *c iov[0].iov_len = snprintf(metainfo, 32, "vchan@%p rd", ctrl); iov[1].iov_base = data; iov[1].iov_len = size; - writev(-1, iov, 2); + if (writev(-1, iov, 2)); } if (send_notify(ctrl, VCHAN_NOTIFY_READ)) return -1;
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 15 of 18] tools/blktap2: remove static string table from header file
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046901 -7200 # Node ID af687dd9e9e0ebf3e68fd9413c027d0d0e8b7a33 # Parent 0966600a98f1b3a4707fa3bfae24d207d424c452 tools/blktap2: remove static string table from header file -O2 -Wall -Werror triggers these warnings: ../../include/vhd.h:109: warning: ''HD_TYPE_STR'' defined but not used Since its used only in one place, move it to the .c file. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 0966600a98f1 -r af687dd9e9e0 tools/blktap2/include/vhd.h --- a/tools/blktap2/include/vhd.h +++ b/tools/blktap2/include/vhd.h @@ -105,17 +105,6 @@ static const char HD_COOKIE[9] = "cone #define HD_TYPE_DYNAMIC 3 /* dynamic disk */ #define HD_TYPE_DIFF 4 /* differencing disk */ -/* String table for hd.type */ -static const char *HD_TYPE_STR[7] = { - "None", /* 0 */ - "Reserved (deprecated)", /* 1 */ - "Fixed hard disk", /* 2 */ - "Dynamic hard disk", /* 3 */ - "Differencing hard disk", /* 4 */ - "Reserved (deprecated)", /* 5 */ - "Reserved (deprecated)" /* 6 */ -}; - #define HD_TYPE_MAX 6 struct prt_loc { diff -r 0966600a98f1 -r af687dd9e9e0 tools/blktap2/vhd/lib/vhd-util-read.c --- a/tools/blktap2/vhd/lib/vhd-util-read.c +++ b/tools/blktap2/vhd/lib/vhd-util-read.c @@ -34,6 +34,17 @@ #include "libvhd.h" #include "vhd-util.h" +/* String table for hd.type */ +static const char *HD_TYPE_STR[7] = { + "None", /* 0 */ + "Reserved (deprecated)", /* 1 */ + "Fixed hard disk", /* 2 */ + "Dynamic hard disk", /* 3 */ + "Differencing hard disk", /* 4 */ + "Reserved (deprecated)", /* 5 */ + "Reserved (deprecated)" /* 6 */ +}; + #define nsize 15 static char nbuf[nsize];
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 16 of 18] tools/blktap2: fix build errors caused by Werror, remove blkif_op_name
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333046917 -7200 # Node ID 9dbadf67b1b76d5864d1db715c1cda72cff53d16 # Parent af687dd9e9e0ebf3e68fd9413c027d0d0e8b7a33 tools/blktap2: fix build errors caused by Werror, remove blkif_op_name -O2 -Wall -Werror triggers these warnings: ../include/blktaplib.h:235: warning: ''blkif_op_name'' defined but not used blkif_op_name[] is odd and appearently not used according to google, except in an 7 years old blkdump.c which would not compile anyway with current blktap. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r af687dd9e9e0 -r 9dbadf67b1b7 tools/blktap2/include/blktaplib.h --- a/tools/blktap2/include/blktaplib.h +++ b/tools/blktap2/include/blktaplib.h @@ -228,15 +228,4 @@ typedef struct msg_lock { ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * getpagesize()) + \ ((_seg) * getpagesize())) -/* Defines that are only used by library clients */ - -#ifndef __COMPILING_BLKTAP_LIB - -static char *blkif_op_name[] = { - [BLKIF_OP_READ] = "READ", - [BLKIF_OP_WRITE] = "WRITE", -}; - -#endif /* __COMPILING_BLKTAP_LIB */ - #endif /* __BLKTAPLIB_H__ */
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333048998 -7200 # Node ID 8f3eaf8d99f50288eaef0b4c5703d65bb4cb30bd # Parent 9dbadf67b1b76d5864d1db715c1cda72cff53d16 tools/blktap2: remove unused labels vhd-util-read.c:478:2: warning: label ''print'' defined but not used [-Wunused-label] vhd-util-set-field.c:99:2: warning: label ''done'' defined but not used [-Wunused-label] Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 9dbadf67b1b7 -r 8f3eaf8d99f5 tools/blktap2/vhd/lib/vhd-util-read.c --- a/tools/blktap2/vhd/lib/vhd-util-read.c +++ b/tools/blktap2/vhd/lib/vhd-util-read.c @@ -475,7 +475,6 @@ vhd_test_bitmap(vhd_context_t *vhd, uint else bit = vhd_bitmap_test(vhd, buf, blk); - print: printf("block %s: ", conv(hex, blk)); printf("sec: %s: %d\n", conv(hex, sec), bit); } diff -r 9dbadf67b1b7 -r 8f3eaf8d99f5 tools/blktap2/vhd/lib/vhd-util-set-field.c --- a/tools/blktap2/vhd/lib/vhd-util-set-field.c +++ b/tools/blktap2/vhd/lib/vhd-util-set-field.c @@ -96,7 +96,6 @@ vhd_util_set_field(int argc, char **argv err = vhd_write_footer(&vhd, &vhd.footer); - done: vhd_close(&vhd); return err;
Olaf Hering
2012-Mar-30 08:25 UTC
[PATCH 18 of 18] tools/blktap2: fix build errors caused by Werror, remove unused variables
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1333095576 -7200 # Node ID 5d4cb03effde3e9c67fea71bcfd868d262798c0b # Parent 8f3eaf8d99f50288eaef0b4c5703d65bb4cb30bd tools/blktap2: fix build errors caused by Werror, remove unused variables -O2 -Wall -Werror triggers these warnings below. The patch removes all listed local variables, a few static arrays in header files will be changed in another patch. xenbus.c: In function ''ueblktap_setup'': xenbus.c:325:6: warning: unused variable ''len'' [-Wunused-variable] xenbus.c:324:25: warning: unused variable ''dev'' [-Wunused-variable] xenbus.c: In function ''ueblktap_probe'': xenbus.c:453:11: warning: unused variable ''blkif'' [-Wunused-variable] xenbus.c:451:42: warning: unused variable ''p'' [-Wunused-variable] -- xs_api.c: In function ''xs_gather'': xs_api.c:64:19: warning: unused variable ''i'' [-Wunused-variable] xs_api.c:64:15: warning: unused variable ''num'' [-Wunused-variable] xs_api.c:63:16: warning: unused variable ''e'' [-Wunused-variable] xs_api.c: In function ''convert_dev_name_to_num'': xs_api.c:216:6: warning: unused variable ''maj'' [-Wunused-variable] xs_api.c: In function ''xs_fire_next_watch'': xs_api.c:344:6: warning: unused variable ''er'' [-Wunused-variable] -- blktapctrl.c: In function ''del_disktype'': blktapctrl.c:257:43: warning: unused variable ''close'' [-Wunused-variable] blktapctrl.c:257:32: warning: unused variable ''count'' [-Wunused-variable] blktapctrl.c: In function ''write_msg'': blktapctrl.c:301:11: warning: unused variable ''seed'' [-Wunused-variable] blktapctrl.c:300:19: warning: unused variable ''img'' [-Wunused-variable] blktapctrl.c: In function ''read_msg'': blktapctrl.c:411:25: warning: unused variable ''len'' [-Wunused-variable] blktapctrl.c:410:8: warning: unused variable ''p'' [-Wunused-variable] blktapctrl.c: In function ''blktapctrl_new_blkif'': blktapctrl.c:656:19: warning: unused variable ''wrctldev'' [-Wunused-variable] blktapctrl.c:656:8: warning: unused variable ''rdctldev'' [-Wunused-variable] blktapctrl.c:655:45: warning: unused variable ''new'' [-Wunused-variable] blktapctrl.c:655:29: warning: unused variable ''fd_write'' [-Wunused-variable] blktapctrl.c:655:20: warning: unused variable ''fd_read'' [-Wunused-variable] blktapctrl.c: In function ''open_ctrl_socket'': blktapctrl.c:765:17: warning: unused variable ''timeout'' [-Wunused-variable] blktapctrl.c:764:9: warning: unused variable ''socks'' [-Wunused-variable] blktapctrl.c: In function ''main'': blktapctrl.c:835:26: warning: unused variable ''xs_fd'' [-Wunused-variable] blktapctrl.c:834:17: warning: unused variable ''ctlinfo'' [-Wunused-variable] blktapctrl.c:833:8: warning: unused variable ''devname'' [-Wunused-variable] -- tapdisk.c: In function ''daemonize'': tapdisk.c:65:6: warning: unused variable ''i'' [-Wunused-variable] tapdisk.c: In function ''add_fd_entry'': tapdisk.c:157:6: warning: unused variable ''i'' [-Wunused-variable] tapdisk.c: In function ''read_msg'': tapdisk.c:372:36: warning: unused variable ''io_fd'' [-Wunused-variable] tapdisk.c:372:27: warning: unused variable ''tap_fd'' [-Wunused-variable] tapdisk.c: In function ''do_cow_read'': tapdisk.c:596:11: warning: unused variable ''early'' [-Wunused-variable] tapdisk.c: In function ''get_io_request'': tapdisk.c:647:7: warning: unused variable ''done'' [-Wunused-variable] tapdisk.c:634:6: warning: unused variable ''early'' [-Wunused-variable] tapdisk.c:629:24: warning: unused variable ''rc'' [-Wunused-variable] tapdisk.c: In function ''main'': tapdisk.c:769:18: warning: unused variable ''writefds'' [-Wunused-variable] tapdisk.c:768:8: warning: unused variable ''p'' [-Wunused-variable] tapdisk.c:767:11: warning: unused variable ''msglen'' [-Wunused-variable] tapdisk.c:767:6: warning: unused variable ''len'' [-Wunused-variable] -- block-aio.c: In function ''get_image_info'': block-aio.c:67:17: warning: unused variable ''statBuf'' [-Wunused-variable] block-aio.c:66:16: warning: unused variable ''total_size'' [-Wunused-variable] block-aio.c:65:7: warning: unused variable ''size'' [-Wunused-variable] block-aio.c: In function ''tdaio_open'': block-aio.c:123:6: warning: unused variable ''i'' [-Wunused-variable] -- block-sync.c: In function ''get_image_info'': block-sync.c:59:17: warning: unused variable ''statBuf'' [-Wunused-variable] block-sync.c:58:16: warning: unused variable ''total_size'' [-Wunused-variable] block-sync.c:57:7: warning: unused variable ''size'' [-Wunused-variable] block-sync.c: In function ''tdsync_open'': block-sync.c:114:6: warning: unused variable ''i'' [-Wunused-variable] -- block-ram.c: In function ''get_image_info'': block-ram.c:69:17: warning: unused variable ''statBuf'' [-Wunused-variable] block-ram.c:68:16: warning: unused variable ''total_size'' [-Wunused-variable] block-ram.c:67:7: warning: unused variable ''size'' [-Wunused-variable] block-ram.c: In function ''tdram_queue_read'': block-ram.c:228:22: warning: unused variable ''prv'' [-Wunused-variable] block-ram.c: In function ''tdram_queue_write'': block-ram.c:242:22: warning: unused variable ''prv'' [-Wunused-variable] block-ram.c: In function ''tdram_close'': block-ram.c:260:22: warning: unused variable ''prv'' [-Wunused-variable] -- block-qcow.c: In function ''tdqcow_open'': block-qcow.c:725:10: warning: unused variable ''len'' [-Wunused-variable] block-qcow.c: In function ''tdqcow_queue_write'': block-qcow.c:1012:6: warning: unused variable ''ret'' [-Wunused-variable] block-qcow.c: In function ''tdqcow_do_callbacks'': block-qcow.c:1102:41: warning: unused variable ''ptr'' [-Wunused-variable] block-qcow.c:1102:13: warning: unused variable ''ret'' [-Wunused-variable] block-qcow.c: In function ''qcow_create'': block-qcow.c:1146:21: warning: unused variable ''adjust'' [-Wunused-variable] -- block-qcow2.c: In function ''qcow_read'': block-qcow2.c:955:32: warning: unused variable ''n1'' [-Wunused-variable] block-qcow2.c: In function ''qcow_queue_write'': block-qcow2.c:1148:17: warning: unused variable ''src_buf'' [-Wunused-variable] block-qcow2.c: In function ''qcow_do_callbacks'': block-qcow2.c:1864:34: warning: unused variable ''ptr'' [-Wunused-variable] block-qcow2.c:1864:6: warning: unused variable ''ret'' [-Wunused-variable] -- tapaio.c: In function ''tap_aio_init'': tapaio.c:186:7: warning: unused variable ''ioidx'' [-Wunused-variable] -- img2qcow.c: In function ''print_bytes'': img2qcow.c:66:7: warning: unused variable ''i'' [-Wunused-variable] img2qcow.c: In function ''get_image_info'': img2qcow.c:107:17: warning: unused variable ''statBuf'' [-Wunused-variable] img2qcow.c:106:16: warning: unused variable ''total_size'' [-Wunused-variable] img2qcow.c:105:7: warning: unused variable ''size'' [-Wunused-variable] -- qcow2raw.c: In function ''print_bytes'': qcow2raw.c:70:7: warning: unused variable ''i'' [-Wunused-variable] qcow2raw.c: In function ''main'': qcow2raw.c:151:24: warning: unused variable ''input'' [-Wunused-variable] qcow2raw.c:151:20: warning: unused variable ''len'' [-Wunused-variable] -- lvm-util.c: In function ''lvm_scan_lvs'': lvm-util.c:221:29: warning: unused variable ''dev'' [-Wunused-variable] -- libvhd.c: In function ''vhd_read_header'': libvhd.c:1031:6: warning: unused variable ''err'' [-Wunused-variable] libvhd.c: In function ''vhd_write_header'': libvhd.c:2011:6: warning: unused variable ''err'' [-Wunused-variable] libvhd.c: In function ''vhd_write_bitmap'': libvhd.c:2146:9: warning: unused variable ''secs'' [-Wunused-variable] libvhd.c: In function ''__vhd_io_allocate_block'': libvhd.c:3206:6: warning: unused variable ''i'' [-Wunused-variable] -- libvhd-journal.c: In function ''vhd_journal_update'': libvhd-journal.c:356:8: warning: unused variable ''eof'' [-Wunused-variable] libvhd-journal.c: In function ''vhd_journal_add_metadata'': libvhd-journal.c:610:8: warning: unused variable ''eof'' [-Wunused-variable] libvhd-journal.c: In function ''vhd_journal_create'': libvhd-journal.c:1259:14: warning: unused variable ''stats'' [-Wunused-variable] libvhd-journal.c:1258:8: warning: unused variable ''off'' [-Wunused-variable] libvhd-journal.c:1257:9: warning: unused variable ''size'' [-Wunused-variable] libvhd-journal.c:1256:6: warning: unused variable ''i'' [-Wunused-variable] libvhd-journal.c:1255:8: warning: unused variable ''buf'' [-Wunused-variable] -- vhd-util-read.c: In function ''vhd_print_header'': vhd-util-read.c:73:47: warning: unused variable ''out'' [-Wunused-variable] vhd-util-read.c: In function ''vhd_print_footer'': vhd-util-read.c:108:50: warning: unused variable ''cksm_save'' [-Wunused-variable] -- vhd-util-resize.c: In function ''vhd_dynamic_grow'': vhd-util-resize.c:880:6: warning: unused variable ''i'' [-Wunused-variable] -- vhd-util-set-field.c: In function ''vhd_util_set_field'': vhd-util-set-field.c:40:8: warning: unused variable ''eof'' [-Wunused-variable] -- vhd-util-scan.c: In function ''vhd_util_scan_pretty_allocate_list'': vhd-util-scan.c:118:20: warning: unused variable ''list'' [-Wunused-variable] vhd-util-scan.c: In function ''vhd_util_scan_extract_volume_name'': vhd-util-scan.c:446:6: warning: unused variable ''err'' [-Wunused-variable] vhd-util-scan.c: In function ''vhd_util_scan_get_parent'': vhd-util-scan.c:513:6: warning: unused variable ''i'' [-Wunused-variable] vhd-util-scan.c: In function ''vhd_util_scan_open_volume'': vhd-util-scan.c:681:6: warning: unused variable ''err'' [-Wunused-variable] -- vhd-util-check.c: In function ''vhd_util_check_validate_parent'': vhd-util-check.c:312:11: warning: unused variable ''status'' [-Wunused-variable] vhd-util-check.c: In function ''vhd_util_check'': vhd-util-check.c:928:16: warning: unused variable ''vhd'' [-Wunused-variable] -- libvhd.c: In function ''vhd_read_header'': libvhd.c:1031:6: warning: unused variable ''err'' [-Wunused-variable] libvhd.c: In function ''vhd_write_header'': libvhd.c:2011:6: warning: unused variable ''err'' [-Wunused-variable] libvhd.c: In function ''vhd_write_bitmap'': libvhd.c:2146:9: warning: unused variable ''secs'' [-Wunused-variable] libvhd.c: In function ''__vhd_io_allocate_block'': libvhd.c:3206:6: warning: unused variable ''i'' [-Wunused-variable] -- libvhd-journal.c: In function ''vhd_journal_update'': libvhd-journal.c:356:8: warning: unused variable ''eof'' [-Wunused-variable] libvhd-journal.c: In function ''vhd_journal_add_metadata'': libvhd-journal.c:610:8: warning: unused variable ''eof'' [-Wunused-variable] libvhd-journal.c: In function ''vhd_journal_create'': libvhd-journal.c:1259:14: warning: unused variable ''stats'' [-Wunused-variable] libvhd-journal.c:1258:8: warning: unused variable ''off'' [-Wunused-variable] libvhd-journal.c:1257:9: warning: unused variable ''size'' [-Wunused-variable] libvhd-journal.c:1256:6: warning: unused variable ''i'' [-Wunused-variable] libvhd-journal.c:1255:8: warning: unused variable ''buf'' [-Wunused-variable] -- vhd-util-read.c: In function ''vhd_print_header'': vhd-util-read.c:73:47: warning: unused variable ''out'' [-Wunused-variable] vhd-util-read.c: In function ''vhd_print_footer'': vhd-util-read.c:108:50: warning: unused variable ''cksm_save'' [-Wunused-variable] -- vhd-util-resize.c: In function ''vhd_dynamic_grow'': vhd-util-resize.c:880:6: warning: unused variable ''i'' [-Wunused-variable] -- vhd-util-set-field.c: In function ''vhd_util_set_field'': vhd-util-set-field.c:40:8: warning: unused variable ''eof'' [-Wunused-variable] -- vhd-util-scan.c: In function ''vhd_util_scan_pretty_allocate_list'': vhd-util-scan.c:118:20: warning: unused variable ''list'' [-Wunused-variable] vhd-util-scan.c: In function ''vhd_util_scan_extract_volume_name'': vhd-util-scan.c:446:6: warning: unused variable ''err'' [-Wunused-variable] vhd-util-scan.c: In function ''vhd_util_scan_get_parent'': vhd-util-scan.c:513:6: warning: unused variable ''i'' [-Wunused-variable] vhd-util-scan.c: In function ''vhd_util_scan_open_volume'': vhd-util-scan.c:681:6: warning: unused variable ''err'' [-Wunused-variable] -- vhd-util-check.c: In function ''vhd_util_check_validate_parent'': vhd-util-check.c:312:11: warning: unused variable ''status'' [-Wunused-variable] vhd-util-check.c: In function ''vhd_util_check'': vhd-util-check.c:928:16: warning: unused variable ''vhd'' [-Wunused-variable] -- ../../lvm/lvm-util.c: In function ''lvm_scan_lvs'': ../../lvm/lvm-util.c:221:29: warning: unused variable ''dev'' [-Wunused-variable] -- tapdisk-vbd.c: In function ''tapdisk_vbd_add_block_cache'': tapdisk-vbd.c:202:15: warning: unused variable ''driver'' [-Wunused-variable] tapdisk-vbd.c: In function ''tapdisk_vbd_open_level'': tapdisk-vbd.c:316:15: warning: unused variable ''driver'' [-Wunused-variable] tapdisk-vbd.c: In function ''__tapdisk_vbd_open_vdi'': tapdisk-vbd.c:389:20: warning: unused variable ''images'' [-Wunused-variable] tapdisk-vbd.c: In function ''__tapdisk_vbd_complete_td_request'': tapdisk-vbd.c:1199:17: warning: unused variable ''image'' [-Wunused-variable] -- tapdisk-control.c: In function ''tapdisk_control_allocate_connection'': tapdisk-control.c:92:9: warning: unused variable ''sz'' [-Wunused-variable] tapdisk-control.c: In function ''tapdisk_control_list'': tapdisk-control.c:255:13: warning: unused variable ''i'' [-Wunused-variable] tapdisk-control.c: In function ''tapdisk_control_attach_vbd'': tapdisk-control.c:317:10: warning: unused variable ''image'' [-Wunused-variable] tapdisk-control.c:316:24: warning: unused variable ''params'' [-Wunused-variable] tapdisk-control.c: In function ''tapdisk_control_create_socket'': tapdisk-control.c:761:11: warning: unused variable ''flags'' [-Wunused-variable] tapdisk-control.c: In function ''tapdisk_control_open'': tapdisk-control.c:832:6: warning: unused variable ''err'' [-Wunused-variable] -- tapdisk-interface.c: In function ''td_load'': tapdisk-interface.c:40:6: warning: unused variable ''err'' [-Wunused-variable] -- tapdisk-server.c: In function ''tapdisk_server_kick_responses'': tapdisk-server.c:183:6: warning: unused variable ''n'' [-Wunused-variable] -- tapdisk-queue.c: In function ''tapdisk_rwio_setup'': tapdisk-queue.c:197:6: warning: unused variable ''err'' [-Wunused-variable] tapdisk-queue.c: In function ''tapdisk_lio_setup'': tapdisk-queue.c:477:9: warning: unused variable ''sz'' [-Wunused-variable] tapdisk-queue.c: In function ''tapdisk_init_queue'': tapdisk-queue.c:611:6: warning: unused variable ''i'' [-Wunused-variable] -- tapdisk-filter.c: In function ''check_data'': tapdisk-filter.c:159:14: warning: unused variable ''sec'' [-Wunused-variable] -- tapdisk-utils.c: In function ''tapdisk_get_image_size'': tapdisk-utils.c:114:6: warning: unused variable ''ret'' [-Wunused-variable] -- io-optimize.c: In function ''io_merge'': io-optimize.c:222:15: warning: unused variable ''ophead'' [-Wunused-variable] -- block-aio.c: In function ''tdaio_get_image_info'': block-aio.c:69:17: warning: unused variable ''statBuf'' [-Wunused-variable] block-aio.c:68:16: warning: unused variable ''total_size'' [-Wunused-variable] block-aio.c:67:7: warning: unused variable ''size'' [-Wunused-variable] -- block-ram.c: In function ''get_image_info'': block-ram.c:60:17: warning: unused variable ''statBuf'' [-Wunused-variable] block-ram.c:59:16: warning: unused variable ''total_size'' [-Wunused-variable] block-ram.c:58:7: warning: unused variable ''size'' [-Wunused-variable] block-ram.c: In function ''tdram_queue_read'': block-ram.c:203:22: warning: unused variable ''prv'' [-Wunused-variable] block-ram.c: In function ''tdram_queue_write'': block-ram.c:214:22: warning: unused variable ''prv'' [-Wunused-variable] block-ram.c: In function ''tdram_close'': block-ram.c:227:22: warning: unused variable ''prv'' [-Wunused-variable] -- block-vhd.c: In function ''_vhd_close'': block-vhd.c:729:21: warning: unused variable ''bm'' [-Wunused-variable] block-vhd.c: In function ''vhd_validate_parent'': block-vhd.c:776:14: warning: unused variable ''stats'' [-Wunused-variable] block-vhd.c:775:11: warning: unused variable ''status'' [-Wunused-variable] block-vhd.c: In function ''allocate_block'': block-vhd.c:1383:8: warning: unused variable ''zeros'' [-Wunused-variable] block-vhd.c: In function ''start_new_bitmap_transaction'': block-vhd.c:1863:9: warning: unused variable ''error'' [-Wunused-variable] -- block-log.c: In function ''shmem_open'': block-log.c:220:10: warning: unused variable ''l'' [-Wunused-variable] block-log.c:220:7: warning: unused variable ''i'' [-Wunused-variable] block-log.c: In function ''ctl_kick'': block-log.c:489:22: warning: unused variable ''rspend'' [-Wunused-variable] block-log.c:489:12: warning: unused variable ''rspstart'' [-Wunused-variable] block-log.c: In function ''ctl_request'': block-log.c:560:11: warning: unused variable ''i'' [-Wunused-variable] block-log.c: In function ''tdlog_queue_write'': block-log.c:638:7: warning: unused variable ''rc'' [-Wunused-variable] -- block-qcow.c: In function ''gen_cksum'': block-qcow.c:86:7: warning: unused variable ''i'' [-Wunused-variable] block-qcow.c: In function ''init_aio_state'': block-qcow.c:104:18: warning: unused variable ''bs'' [-Wunused-variable] block-qcow.c:103:9: warning: unused variable ''ret'' [-Wunused-variable] block-qcow.c: In function ''tdqcow_open'': block-qcow.c:868:10: warning: unused variable ''len'' [-Wunused-variable] block-qcow.c: In function ''tdqcow_queue_read'': block-qcow.c:987:19: warning: unused variable ''prv'' [-Wunused-variable] block-qcow.c:985:36: warning: unused variable ''i'' [-Wunused-variable] block-qcow.c:985:6: warning: unused variable ''ret'' [-Wunused-variable] block-qcow.c: In function ''tdqcow_queue_write'': block-qcow.c:1057:19: warning: unused variable ''prv'' [-Wunused-variable] block-qcow.c:1056:16: warning: unused variable ''cb'' [-Wunused-variable] block-qcow.c:1054:36: warning: unused variable ''i'' [-Wunused-variable] block-qcow.c:1054:6: warning: unused variable ''ret'' [-Wunused-variable] block-qcow.c: In function ''qcow_create'': block-qcow.c:1181:21: warning: unused variable ''adjust'' [-Wunused-variable] -- block-remus.c: In function ''ramdisk_start_flush'': block-remus.c:581:19: warning: unused variable ''batchlen'' [-Wunused-variable] block-remus.c:581:9: warning: unused variable ''j'' [-Wunused-variable] block-remus.c:580:6: warning: unused variable ''rc'' [-Wunused-variable] block-remus.c:578:12: warning: unused variable ''key'' [-Wunused-variable] block-remus.c: In function ''primary_do_connect'': block-remus.c:749:6: warning: unused variable ''rc'' [-Wunused-variable] block-remus.c: In function ''remus_client_event'': block-remus.c:1031:6: warning: unused variable ''rc'' [-Wunused-variable] block-remus.c: In function ''backup_queue_read'': block-remus.c:1154:6: warning: unused variable ''i'' [-Wunused-variable] block-remus.c: In function ''backup_queue_write'': block-remus.c:1171:24: warning: unused variable ''s'' [-Wunused-variable] block-remus.c: In function ''backup_start'': block-remus.c:1186:6: warning: unused variable ''fd'' [-Wunused-variable] block-remus.c: In function ''server_do_wreq'': block-remus.c:1203:11: warning: unused variable ''rc'' [-Wunused-variable] block-remus.c:1201:24: warning: unused variable ''twreq'' [-Wunused-variable] block-remus.c: In function ''get_args'': block-remus.c:1433:9: warning: unused variable ''ipver'' [-Wunused-variable] block-remus.c:1432:9: warning: unused variable ''addr'' [-Wunused-variable] -- td.c: In function ''td_coalesce'': td.c:360:15: warning: unused variable ''pname'' [-Wunused-variable] td.c: In function ''td_set_field'': td.c:548:11: warning: unused variable ''i'' [-Wunused-variable] td.c:548:6: warning: unused variable ''ret'' [-Wunused-variable] -- tapdisk-client.c: In function ''writelog_map'': tapdisk-client.c:244:9: warning: unused variable ''shm'' [-Wunused-variable] -- tapdisk-stream.c: In function ''main'': tapdisk-stream.c:550:21: warning: unused variable ''info'' [-Wunused-variable] -- tapdisk-diff.c: In function ''tapdisk_stream_enqueue2'': tapdisk-diff.c:469:9: warning: unused variable ''blk'' [-Wunused-variable] tapdisk-diff.c:469:6: warning: unused variable ''i'' [-Wunused-variable] tapdisk-diff.c: In function ''main'': tapdisk-diff.c:720:21: warning: unused variable ''info'' [-Wunused-variable] -- lock.c: In function ''main'': lock.c:962:13: warning: unused variable ''dlock'' [-Wunused-variable] -- img2qcow.c: In function ''print_bytes'': img2qcow.c:84:7: warning: unused variable ''i'' [-Wunused-variable] img2qcow.c: In function ''get_image_info'': img2qcow.c:117:17: warning: unused variable ''statBuf'' [-Wunused-variable] img2qcow.c:116:16: warning: unused variable ''total_size'' [-Wunused-variable] img2qcow.c:115:7: warning: unused variable ''size'' [-Wunused-variable] img2qcow.c: In function ''main'': img2qcow.c:167:17: warning: unused variable ''timeout'' [-Wunused-variable] img2qcow.c: At top level: img2qcow.c:73:17: warning: ''read_idx'' defined but not used [-Wunused-variable] img2qcow.c:76:27: warning: ''written'' defined but not used [-Wunused-variable] -- qcow2raw.c: In function ''print_bytes'': qcow2raw.c:90:7: warning: unused variable ''i'' [-Wunused-variable] qcow2raw.c: In function ''send_read_responses'': qcow2raw.c:147:6: warning: unused variable ''ret'' [-Wunused-variable] qcow2raw.c: In function ''main'': qcow2raw.c:201:24: warning: unused variable ''input'' [-Wunused-variable] qcow2raw.c:201:20: warning: unused variable ''len'' [-Wunused-variable] qcow2raw.c: At top level: qcow2raw.c:74:17: warning: ''read_idx'' defined but not used [-Wunused-variable] -- tap-ctl-list.c: In function ''tap_ctl_alloc_list'': tap-ctl-list.c:116:22: warning: unused variable ''entry'' [-Wunused-variable] tap-ctl-list.c: In function ''_tap_ctl_find_tapdisks'': tap-ctl-list.c:274:7: warning: unused variable ''n'' [-Wunused-variable] -- tap-ctl-spawn.c: In function ''__tap_ctl_spawn'': tap-ctl-spawn.c:42:6: warning: unused variable ''err'' [-Wunused-variable] -- tap-ctl-check.c: In function ''tap_ctl_check'': tap-ctl-check.c:68:8: warning: unused variable ''uid'' [-Wunused-variable] -- tap-ctl-list.c: In function ''tap_ctl_alloc_list'': tap-ctl-list.c:116:22: warning: unused variable ''entry'' [-Wunused-variable] tap-ctl-list.c: In function ''_tap_ctl_find_tapdisks'': tap-ctl-list.c:274:7: warning: unused variable ''n'' [-Wunused-variable] -- tap-ctl-spawn.c: In function ''__tap_ctl_spawn'': tap-ctl-spawn.c:42:6: warning: unused variable ''err'' [-Wunused-variable] -- tap-ctl-check.c: In function ''tap_ctl_check'': tap-ctl-check.c:68:8: warning: unused variable ''uid'' [-Wunused-variable] Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/control/tap-ctl-check.c --- a/tools/blktap2/control/tap-ctl-check.c +++ b/tools/blktap2/control/tap-ctl-check.c @@ -65,7 +65,6 @@ int tap_ctl_check(const char **msg) { int err; - uid_t uid; err = tap_ctl_check_blktap(msg); if (err) diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/control/tap-ctl-list.c --- a/tools/blktap2/control/tap-ctl-list.c +++ b/tools/blktap2/control/tap-ctl-list.c @@ -125,8 +125,6 @@ tap_ctl_alloc_list(int n) memset(list, 0, size); for (i = 0; i < n; ++i) { - tap_list_t *entry; - entry = malloc(sizeof(tap_list_t)); if (!entry) goto fail; @@ -271,7 +269,6 @@ _tap_ctl_find_tapdisks(struct tapdisk ** for (i = 0; i < glbuf.gl_pathc; ++i) { struct tapdisk *tap; - int n; tap = &tapv[n_taps]; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/control/tap-ctl-spawn.c --- a/tools/blktap2/control/tap-ctl-spawn.c +++ b/tools/blktap2/control/tap-ctl-spawn.c @@ -39,7 +39,7 @@ static pid_t __tap_ctl_spawn(int *readfd) { - int err, child, channel[2]; + int child, channel[2]; char *tapdisk; if (pipe(channel)) { diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/block-aio.c --- a/tools/blktap2/drivers/block-aio.c +++ b/tools/blktap2/drivers/block-aio.c @@ -64,9 +64,6 @@ struct tdaio_state { static int tdaio_get_image_info(int fd, td_disk_info_t *info) { int ret; - long size; - unsigned long total_size; - struct statvfs statBuf; struct stat stat; ret = fstat(fd, &stat); diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/block-log.c --- a/tools/blktap2/drivers/block-log.c +++ b/tools/blktap2/drivers/block-log.c @@ -217,7 +217,7 @@ static char* ctl_makepath(const char* na static int shmem_open(struct tdlog_state* s, const char* name) { - int i, l, fd; + int fd; /* device name -> path */ if (asprintf(&s->shmpath, "/log_%s.wlog", name) < 0) { @@ -486,7 +486,6 @@ static int ctl_kick(struct tdlog_state* log_request_t req; /* XXX testing */ - RING_IDX rspstart, rspend; log_response_t rsp; struct log_ctlmsg msg; int rc; @@ -557,7 +556,7 @@ static void ctl_request(event_id_t id, c { struct tdlog_state* s = (struct tdlog_state*)private; struct log_ctlmsg msg; - int rc, i, fd = -1; + int rc, fd = -1; fd = ctl_find_connection(s, id); if (fd == -1) @@ -635,7 +634,6 @@ static void tdlog_queue_read(td_driver_t static void tdlog_queue_write(td_driver_t* driver, td_request_t treq) { struct tdlog_state* s = (struct tdlog_state*)driver->data; - int rc; writelog_set(s, treq.sec, treq.secs); td_forward_request(treq); diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/block-qcow.c --- a/tools/blktap2/drivers/block-qcow.c +++ b/tools/blktap2/drivers/block-qcow.c @@ -83,7 +83,6 @@ static int decompress_cluster(struct tdq uint32_t gen_cksum(char *ptr, int len) { - int i; uint32_t md[4]; /* Generate checksum */ @@ -100,8 +99,7 @@ static void free_aio_state(struct tdqcow static int init_aio_state(td_driver_t *driver) { - int i, ret; - td_disk_info_t *bs = &(driver->info); + int i; struct tdqcow_state *s = (struct tdqcow_state *)driver->data; // A segment (i.e. a page) can span multiple clusters @@ -865,7 +863,7 @@ out: /* Open the disk file and initialize qcow state. */ int tdqcow_open (td_driver_t *driver, const char *name, td_flag_t flags) { - int fd, len, i, ret, size, o_flags; + int fd, i, ret, size, o_flags; td_disk_info_t *bs = &(driver->info); struct tdqcow_state *s = (struct tdqcow_state *)driver->data; QCowHeader header; @@ -982,9 +980,8 @@ fail: void tdqcow_queue_read(td_driver_t *driver, td_request_t treq) { struct tdqcow_state *s = (struct tdqcow_state *)driver->data; - int ret = 0, index_in_cluster, n, i; + int index_in_cluster, n, i; uint64_t cluster_offset, sector, nb_sectors; - struct qcow_prv* prv; td_request_t clone = treq; char* buf = treq.buf; @@ -1006,7 +1003,6 @@ void tdqcow_queue_read(td_driver_t *driv } if(!cluster_offset) { - int i; /* Forward entire request if possible. */ for(i=0; i<nb_sectors; i++) if(get_cluster_offset(s, (sector+i) << 9, 0, 0, 0, 0)) @@ -1051,10 +1047,8 @@ done: void tdqcow_queue_write(td_driver_t *driver, td_request_t treq) { struct tdqcow_state *s = (struct tdqcow_state *)driver->data; - int ret = 0, index_in_cluster, n, i; + int index_in_cluster, n; uint64_t cluster_offset, sector, nb_sectors; - td_callback_t cb; - struct qcow_prv* prv; char* buf = treq.buf; td_request_t clone=treq; @@ -1178,7 +1172,7 @@ int qcow_create(const char *filename, ui const char *backing_file, int sparse) { int fd, header_size, backing_filename_len, l1_size, i; - int shift, length, adjust, flags = 0, ret = 0; + int shift, length, flags = 0, ret = 0; QCowHeader header; QCowHeader_ext exthdr; char backing_filename[PATH_MAX], *ptr; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/block-ram.c --- a/tools/blktap2/drivers/block-ram.c +++ b/tools/blktap2/drivers/block-ram.c @@ -55,9 +55,6 @@ struct tdram_state { static int get_image_info(int fd, td_disk_info_t *info) { int ret; - long size; - unsigned long total_size; - struct statvfs statBuf; struct stat stat; ret = fstat(fd, &stat); @@ -200,7 +197,6 @@ done: void tdram_queue_read(td_driver_t *driver, td_request_t treq) { - struct tdram_state *prv = (struct tdram_state *)driver->data; int size = treq.secs * driver->info.sector_size; uint64_t offset = treq.sec * (uint64_t)driver->info.sector_size; @@ -211,7 +207,6 @@ void tdram_queue_read(td_driver_t *drive void tdram_queue_write(td_driver_t *driver, td_request_t treq) { - struct tdram_state *prv = (struct tdram_state *)driver->data; int size = treq.secs * driver->info.sector_size; uint64_t offset = treq.sec * (uint64_t)driver->info.sector_size; @@ -224,8 +219,6 @@ void tdram_queue_write(td_driver_t *driv int tdram_close(td_driver_t *driver) { - struct tdram_state *prv = (struct tdram_state *)driver->data; - connections--; return 0; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/block-remus.c --- a/tools/blktap2/drivers/block-remus.c +++ b/tools/blktap2/drivers/block-remus.c @@ -575,10 +575,8 @@ static int ramdisk_flush(td_driver_t *dr static int ramdisk_start_flush(td_driver_t *driver) { struct tdremus_state *s = (struct tdremus_state *)driver->data; - uint64_t* key; char* buf; - int rc = 0; - int i, j, count, batchlen; + int i, count; uint64_t* sectors; if (!hashtable_count(s->ramdisk.h)) { @@ -746,7 +744,6 @@ static int primary_do_connect(struct tdr { event_id_t id; int fd; - int rc; int flags; RPRINTF("client connecting to %s:%d...\n", inet_ntoa(state->sa.sin_addr), ntohs(state->sa.sin_port)); @@ -1028,7 +1025,6 @@ static void remus_client_event(event_id_ { struct tdremus_state *s = (struct tdremus_state *)private; char req[5]; - int rc; if (mread(s->stream_fd.fd, req, sizeof(req) - 1) < 0) { /* replication stream closed or otherwise broken (timeout, reset, &c) */ @@ -1151,7 +1147,6 @@ static inline int server_writes_inflight void backup_queue_read(td_driver_t *driver, td_request_t treq) { struct tdremus_state *s = (struct tdremus_state *)driver->data; - int i; if(!remus_image) remus_image = treq.image; @@ -1168,8 +1163,6 @@ void backup_queue_read(td_driver_t *driv /* see above */ void backup_queue_write(td_driver_t *driver, td_request_t treq) { - struct tdremus_state *s = (struct tdremus_state *)driver->data; - /* on a server write, we know the domain has failed over. we must change our * state to unprotected and then have the unprotected queue_write function * handle the write @@ -1183,7 +1176,6 @@ void backup_queue_write(td_driver_t *dri static int backup_start(td_driver_t *driver) { struct tdremus_state *s = (struct tdremus_state *)driver->data; - int fd; if (ramdisk_start(driver) < 0) return -1; @@ -1198,9 +1190,8 @@ static int backup_start(td_driver_t *dri static int server_do_wreq(td_driver_t *driver) { struct tdremus_state *s = (struct tdremus_state *)driver->data; - static tdremus_wire_t twreq; char buf[4096]; - int len, rc; + int len; char header[sizeof(uint32_t) + sizeof(uint64_t)]; uint32_t *sectors = (uint32_t *) header; @@ -1429,9 +1420,6 @@ static int get_args(td_driver_t *driver, /* TODO: do something smarter here */ valid_addr = 0; for(servinfo_itr = servinfo; servinfo_itr != NULL; servinfo_itr = servinfo_itr->ai_next) { - void *addr; - char *ipver; - if (servinfo_itr->ai_family == AF_INET) { valid_addr = 1; memset(&state->sa, 0, sizeof(state->sa)); diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/block-vhd.c --- a/tools/blktap2/drivers/block-vhd.c +++ b/tools/blktap2/drivers/block-vhd.c @@ -726,7 +726,6 @@ _vhd_close(td_driver_t *driver) { int err; struct vhd_state *s; - struct vhd_bitmap *bm; DBG(TLOG_WARN, "vhd_close\n"); s = (struct vhd_state *)driver->data; @@ -772,8 +771,6 @@ int vhd_validate_parent(td_driver_t *child_driver, td_driver_t *parent_driver, td_flag_t flags) { - uint32_t status; - struct stat stats; struct vhd_state *child = (struct vhd_state *)child_driver->data; struct vhd_state *parent; @@ -789,24 +786,6 @@ vhd_validate_parent(td_driver_t *child_d parent = (struct vhd_state *)parent_driver->data; - /* - * This check removed because of cases like: - * - parent VHD marked as ''hidden'' - * - parent VHD modified during coalesce - */ - /* - if (stat(parent->vhd.file, &stats)) { - DPRINTF("ERROR stating parent file %s\n", parent->vhd.file); - return -errno; - } - - if (child->hdr.prt_ts != vhd_time(stats.st_mtime)) { - DPRINTF("ERROR: parent file has been modified since " - "snapshot. Child image no longer valid.\n"); - return -EINVAL; - } - */ - if (vhd_uuid_compare(&child->vhd.header.prt_uuid, &parent->vhd.footer.uuid)) { DPRINTF("ERROR: %s: %s, %s: parent uuid has changed since " "snapshot. Child image no longer valid.\n", @@ -1380,7 +1359,6 @@ update_bat(struct vhd_state *s, uint32_t static int allocate_block(struct vhd_state *s, uint32_t blk) { - char *zeros; int err, gap; uint64_t offset, size; struct vhd_bitmap *bm; @@ -1860,7 +1838,7 @@ signal_completion(struct vhd_request *li static void start_new_bitmap_transaction(struct vhd_state *s, struct vhd_bitmap *bm) { - int i, error = 0; + int i; struct vhd_transaction *tx; struct vhd_request *r, *next; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/io-optimize.c --- a/tools/blktap2/drivers/io-optimize.c +++ b/tools/blktap2/drivers/io-optimize.c @@ -219,7 +219,6 @@ io_merge(struct opioctx *ctx, struct ioc { int i, on_queue; struct iocb *io, **q; - struct opio *ophead; if (!num) return 0; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/tapdisk-client.c --- a/tools/blktap2/drivers/tapdisk-client.c +++ b/tools/blktap2/drivers/tapdisk-client.c @@ -241,7 +241,6 @@ static int ctl_clear_writes(int fd) static int writelog_map(struct writelog* wl) { int fd; - void* shm; if ((fd = shm_open(wl->shmpath, O_RDWR, 0750)) < 0) { BWPRINTF("could not open shared memory at %s: %s", wl->shmpath, diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/tapdisk-control.c --- a/tools/blktap2/drivers/tapdisk-control.c +++ b/tools/blktap2/drivers/tapdisk-control.c @@ -89,7 +89,6 @@ static struct tapdisk_control_connection tapdisk_control_allocate_connection(int fd) { struct tapdisk_control_connection *connection; - size_t sz; connection = calloc(1, sizeof(*connection)); if (!connection) { @@ -252,7 +251,7 @@ tapdisk_control_list(struct tapdisk_cont td_vbd_t *vbd; struct list_head *head; tapdisk_message_t response; - int count, i; + int count; memset(&response, 0, sizeof(response)); response.type = TAPDISK_MESSAGE_LIST_RSP; @@ -313,8 +312,6 @@ tapdisk_control_attach_vbd(struct tapdis tapdisk_message_t response; char *devname; td_vbd_t *vbd; - struct blktap2_params params; - image_t image; int minor, err; /* @@ -758,7 +755,7 @@ tapdisk_control_mkdir(const char *dir) static int tapdisk_control_create_socket(char **socket_path) { - int err, flags; + int err; struct sockaddr_un saddr; err = tapdisk_control_mkdir(BLKTAP2_CONTROL_DIR); @@ -829,8 +826,6 @@ fail: int tapdisk_control_open(char **path) { - int err; - tapdisk_control_initialize(); return tapdisk_control_create_socket(path); diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/tapdisk-filter.c --- a/tools/blktap2/drivers/tapdisk-filter.c +++ b/tools/blktap2/drivers/tapdisk-filter.c @@ -156,7 +156,7 @@ static void check_data(struct tfilter *filter, int type, struct iocb *io) { int rw; - uint64_t i, sec; + uint64_t i; rw = (io->aio_lio_opcode == IO_CMD_PWRITE); diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/tapdisk-interface.c --- a/tools/blktap2/drivers/tapdisk-interface.c +++ b/tools/blktap2/drivers/tapdisk-interface.c @@ -37,7 +37,6 @@ int td_load(td_image_t *image) { - int err; td_image_t *shared; td_driver_t *driver; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/tapdisk-queue.c --- a/tools/blktap2/drivers/tapdisk-queue.c +++ b/tools/blktap2/drivers/tapdisk-queue.c @@ -474,7 +474,6 @@ static int tapdisk_lio_setup(struct tqueue *queue, int qlen) { struct lio *lio = queue->tio_data; - size_t sz; int err; lio->event_id = -1; @@ -608,7 +607,7 @@ int tapdisk_init_queue(struct tqueue *queue, int size, int drv, struct tfilter *filter) { - int i, err; + int err; memset(queue, 0, sizeof(struct tqueue)); diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/tapdisk-server.c --- a/tools/blktap2/drivers/tapdisk-server.c +++ b/tools/blktap2/drivers/tapdisk-server.c @@ -180,7 +180,6 @@ tapdisk_server_submit_tiocbs(void) static void tapdisk_server_kick_responses(void) { - int n; td_vbd_t *vbd, *tmp; tapdisk_server_for_each_vbd(vbd, tmp) diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/tapdisk-utils.c --- a/tools/blktap2/drivers/tapdisk-utils.c +++ b/tools/blktap2/drivers/tapdisk-utils.c @@ -111,7 +111,6 @@ tapdisk_namedup(char **dup, const char * int tapdisk_get_image_size(int fd, uint64_t *_sectors, uint32_t *_sector_size) { - int ret; struct stat stat; uint64_t sectors; uint64_t sector_size; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/tapdisk-vbd.c --- a/tools/blktap2/drivers/tapdisk-vbd.c +++ b/tools/blktap2/drivers/tapdisk-vbd.c @@ -199,7 +199,6 @@ static int tapdisk_vbd_add_block_cache(td_vbd_t *vbd) { int err; - td_driver_t *driver; td_image_t *cache, *image, *target, *tmp; target = NULL; @@ -313,7 +312,6 @@ tapdisk_vbd_open_level(td_vbd_t *vbd, st int type, err; td_image_t *image; td_disk_id_t id; - td_driver_t *driver; name = params; id.name = NULL; @@ -386,7 +384,6 @@ __tapdisk_vbd_open_vdi(td_vbd_t *vbd, td td_flag_t flags; td_image_t *tmp; td_vbd_driver_info_t *driver_info; - struct list_head *images; td_disk_info_t *parent_info = NULL; if (list_empty(&vbd->driver_stack)) @@ -1196,7 +1193,6 @@ __tapdisk_vbd_complete_td_request(td_vbd td_request_t treq, int res) { int err; - td_image_t *image = treq.image; err = (res <= 0 ? res : -res); vbd->secs_pending -= treq.secs; @@ -1216,6 +1212,7 @@ __tapdisk_vbd_complete_td_request(td_vbd } } else { #ifdef MEMSHR + td_image_t *image = treq.image; if (treq.op == TD_OP_READ && td_flag_test(image->flags, TD_OPEN_RDONLY)) { share_tuple_t hnd = treq.memshr_hnd; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/drivers/td.c --- a/tools/blktap2/drivers/td.c +++ b/tools/blktap2/drivers/td.c @@ -545,7 +545,7 @@ td_query(int type, int argc, char *argv[ int td_set_field(int type, int argc, char *argv[]) { - int ret, i, c, cargc; + int c, cargc; struct vdi_field *field; char *name, *value, *cargv[7]; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/lvm/lvm-util.c --- a/tools/blktap2/lvm/lvm-util.c +++ b/tools/blktap2/lvm/lvm-util.c @@ -218,7 +218,7 @@ lvm_scan_lvs(struct vg *vg) struct lv *lv; struct lv_segment seg; uint64_t size, seg_start; - char type[32], name[256], dev[256], devices[1024]; + char type[32], name[256], devices[1024]; if (i >= vg->lv_cnt) break; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/vhd/lib/libvhd-journal.c --- a/tools/blktap2/vhd/lib/libvhd-journal.c +++ b/tools/blktap2/vhd/lib/libvhd-journal.c @@ -353,7 +353,6 @@ vhd_journal_update(vhd_journal_t *j, off char *buf, size_t size, uint32_t type) { int err; - off_t eof; uint64_t *off, off_bak; uint32_t *entries; vhd_journal_entry_t entry; @@ -607,7 +606,6 @@ static int vhd_journal_add_metadata(vhd_journal_t *j) { int err; - off_t eof; vhd_context_t *vhd; vhd = &j->vhd; @@ -1252,11 +1250,7 @@ fail: int vhd_journal_create(vhd_journal_t *j, const char *file, const char *jfile) { - char *buf; - int i, err; - size_t size; - off_t off; - struct stat stats; + int err; memset(j, 0, sizeof(vhd_journal_t)); j->jfd = -1; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/vhd/lib/libvhd.c --- a/tools/blktap2/vhd/lib/libvhd.c +++ b/tools/blktap2/vhd/lib/libvhd.c @@ -1028,7 +1028,6 @@ out: int vhd_read_header(vhd_context_t *ctx, vhd_header_t *header) { - int err; off_t off; if (!vhd_type_dynamic(ctx)) { @@ -2008,7 +2007,6 @@ out: int vhd_write_header(vhd_context_t *ctx, vhd_header_t *header) { - int err; off_t off; if (!vhd_type_dynamic(ctx)) @@ -2143,7 +2141,7 @@ vhd_write_bitmap(vhd_context_t *ctx, uin int err; off_t off; uint64_t blk; - size_t secs, size; + size_t size; if (!vhd_type_dynamic(ctx)) return -EINVAL; @@ -3203,7 +3201,7 @@ __vhd_io_allocate_block(vhd_context_t *c char *buf; size_t size; off_t off, max; - int i, err, gap, spp; + int err, gap, spp; spp = getpagesize() >> VHD_SECTOR_SHIFT; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/vhd/lib/vhd-util-check.c --- a/tools/blktap2/vhd/lib/vhd-util-check.c +++ b/tools/blktap2/vhd/lib/vhd-util-check.c @@ -309,7 +309,6 @@ vhd_util_check_validate_parent(vhd_conte { const char *msg; vhd_context_t parent; - uint32_t status; msg = NULL; @@ -925,7 +924,6 @@ int vhd_util_check(int argc, char **argv) { char *name; - vhd_context_t vhd; int c, err, ignore, parents; if (!argc || !argv) { diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/vhd/lib/vhd-util-read.c --- a/tools/blktap2/vhd/lib/vhd-util-read.c +++ b/tools/blktap2/vhd/lib/vhd-util-read.c @@ -70,7 +70,7 @@ vhd_print_header(vhd_context_t *vhd, vhd { int err; uint32_t cksm; - char uuid[39], time_str[26], cookie[9], out[512], *name; + char uuid[39], time_str[26], cookie[9], *name; printf("VHD Header Summary:\n-------------------\n"); @@ -105,7 +105,7 @@ static void vhd_print_footer(vhd_footer_t *f, int hex) { uint64_t c, h, s; - uint32_t ff_maj, ff_min, cr_maj, cr_min, cksm, cksm_save; + uint32_t ff_maj, ff_min, cr_maj, cr_min, cksm; char time_str[26], creator[5], uuid[39], cookie[9]; printf("VHD Footer Summary:\n-------------------\n"); diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/vhd/lib/vhd-util-resize.c --- a/tools/blktap2/vhd/lib/vhd-util-resize.c +++ b/tools/blktap2/vhd/lib/vhd-util-resize.c @@ -877,7 +877,7 @@ vhd_add_bat_entries(vhd_journal_t *journ static int vhd_dynamic_grow(vhd_journal_t *journal, uint64_t secs) { - int i, err; + int err; off_t eob, eom; vhd_context_t *vhd; vhd_block_t first_block; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/vhd/lib/vhd-util-scan.c --- a/tools/blktap2/vhd/lib/vhd-util-scan.c +++ b/tools/blktap2/vhd/lib/vhd-util-scan.c @@ -115,7 +115,6 @@ static int vhd_util_scan_pretty_allocate_list(int cnt) { int i; - struct vhd_image *list; memset(&scan, 0, sizeof(scan)); @@ -443,7 +442,6 @@ copy_name(char *dst, const char *src) static int vhd_util_scan_extract_volume_name(char *dst, const char *src) { - int err; char copy[VHD_MAX_NAME_LEN], *name, *s, *c; name = strrchr(src, ''/''); @@ -510,7 +508,7 @@ found: static int vhd_util_scan_get_parent(vhd_context_t *vhd, struct vhd_image *image) { - int i, err; + int err; vhd_parent_locator_t *loc; if (!target_vhd(image->target->type)) { @@ -678,7 +676,6 @@ out: static int vhd_util_scan_open_volume(vhd_context_t *vhd, struct vhd_image *image) { - int err; struct target *target; target = image->target; diff -r 8f3eaf8d99f5 -r 5d4cb03effde tools/blktap2/vhd/lib/vhd-util-set-field.c --- a/tools/blktap2/vhd/lib/vhd-util-set-field.c +++ b/tools/blktap2/vhd/lib/vhd-util-set-field.c @@ -37,7 +37,6 @@ vhd_util_set_field(int argc, char **argv { long value; int err, c; - off_t eof; vhd_context_t vhd; char *name, *field;
Olaf Hering
2012-Mar-30 12:44 UTC
Re: [PATCH 18 of 18] tools/blktap2: fix build errors caused by Werror, remove unused variables
On Fri, Mar 30, Olaf Hering wrote:> tools/blktap2: fix build errors caused by Werror, remove unused variables > > -O2 -Wall -Werror triggers these warnings below. > The patch removes all listed local variables, a few static arrays inI forgot to refresh the patch, so the changelog does not match the actual change. I will resend patch #18. Olaf
Ian Jackson
2012-Apr-02 13:47 UTC
Re: [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num
Olaf Hering writes ("[Xen-devel] [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num"):> xs_api.c: In function ''convert_dev_name_to_num'':...> ptr should be increased in each iteration, not the char it points to.These changes from `*p++;'' to `p++'' are correct. But the description is wrong. `*p++'' is the same as `*(p++)'' ie it increments p and then uselessly dereferences it.> - 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";And this hunk seems entirely unexplained. Is it supposed to be a const-correctness fix ? Stylistic improvement ? Ian.
Ian Jackson
2012-Apr-02 13:52 UTC
Re: [PATCH 07 of 18] tools/blktap2: fix build errors caused by Werror in tdqcow_get_parent_id
Olaf Hering writes ("[Xen-devel] [PATCH 07 of 18] tools/blktap2: fix build errors caused by Werror in tdqcow_get_parent_id"):> tools/blktap2: fix build errors caused by Werror in tdqcow_get_parent_id > > -O2 -Wall -Werror triggers these warnings: > > block-qcow.c: In function ''tdqcow_get_parent_id'': > block-qcow.c:1457:17: warning: ''type'' may be used uninitialized in this function [-Wuninitialized] > > The compiler can not know that open() writes to errno so it has to > assume that errno can be zero.Yes.> Since tdqcow_get_image_type() has just > one caller which expects a bool as return type, adjust return codes so > that the compiler knows when ''type'' is initialised.I don''t think this is a step in the right direction. In a better world the caller would report the errno value. Throwing the errno value away is not an improvement.> Signed-off-by: Olaf Hering <olaf@aepfle.de> > > diff -r 51c773447549 -r 16f6fc42abaa tools/blktap2/drivers/block-qcow.c > --- a/tools/blktap2/drivers/block-qcow.c > +++ b/tools/blktap2/drivers/block-qcow.c > @@ -1408,12 +1408,12 @@ tdqcow_get_image_type(const char *file, > > fd = open(file, O_RDONLY); > if (fd == -1) > - return -errno; > + return -1;This can be fixed here by adding assert(errno);> size = read(fd, &header, sizeof(header)); > close(fd); > if (size != sizeof(header)) > - return (errno ? -errno : -EIO); > + return -1;And this seems not to have a problem; surely just leaving it unchanged is sufficient ? Ian.
Ian Jackson
2012-Apr-02 13:53 UTC
Re: [PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback
Olaf Hering writes ("[Xen-devel] [PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback"):> tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback > > -O2 -Wall -Werror triggers these warnings: > > libxl.c: In function ''disk_eject_xswatch_callback'': > libxl.c:928: warning: zero-length printf format stringThere is nothing wrong with zero-length format strings. This warning should be disabled. Please do send a patch to do so. Ian.
Ian Jackson
2012-Apr-02 13:55 UTC
Re: [PATCH 05 of 18] tools/blktap2: fix build errors caused by Werror in vhd_journal_write_entry
Olaf Hering writes ("[Xen-devel] [PATCH 05 of 18] tools/blktap2: fix build errors caused by Werror in vhd_journal_write_entry"):> tools/blktap2: fix build errors caused by Werror in vhd_journal_write_entry...> - err = vhd_journal_write(j, &e, sizeof(vhd_journal_entry_t)); > - if (err) > - err;Surely this should have read `return err;''.> - > - return 0; > + return vhd_journal_write(j, &e, sizeof(vhd_journal_entry_t));I think that would be a better fix than this. Ian.
Ian Jackson
2012-Apr-02 13:59 UTC
Re: [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c
Olaf Hering writes ("[Xen-devel] [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c"):> tools/libvchan: fix build errors caused by -Werror in node-select.c > > -O2 -Wall -Werror triggers these warnings: > > node-select.c:57:6: warning: function declaration isn''t a prototype [-Wstrict-prototypes]These changes are correct.> node-select.c: In function ''vchan_wr'': > node-select.c:60:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]This one is a question of coding style. Apparently libvchan uses mixed statements/declarations, so this should be fixed by changing the warning flags. Ian.
Ian Jackson
2012-Apr-02 14:01 UTC
Re: [PATCH 13 of 18] tools/xenpaging: fix build errors caused by -Werror
Olaf Hering writes ("[Xen-devel] [PATCH 13 of 18] tools/xenpaging: fix build errors caused by -Werror"):> tools/xenpaging: fix build errors caused by -WerrorAcked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Jackson
2012-Apr-02 14:04 UTC
Re: [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num
Ian Jackson writes ("Re: [Xen-devel] [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num"):> Olaf Hering writes ("[Xen-devel] [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num"): > > xs_api.c: In function ''convert_dev_name_to_num'': > ... > > ptr should be increased in each iteration, not the char it points to. > > These changes from `*p++;'' to `p++'' are correct. But the description > is wrong. `*p++'' is the same as `*(p++)'' ie it increments p and then > uselessly dereferences it.It''s been pointed out to me that this rather loose language is unclear. `*p++'' increments p and but dereferences _the old value_ of p. The point I was making is that it does not increment (*p). Ian.
Ian Jackson
2012-Apr-02 14:06 UTC
Re: [PATCH 16 of 18] tools/blktap2: fix build errors caused by Werror, remove blkif_op_name
Olaf Hering writes ("[Xen-devel] [PATCH 16 of 18] tools/blktap2: fix build errors caused by Werror, remove blkif_op_name"):> tools/blktap2: fix build errors caused by Werror, remove blkif_op_name...> -static char *blkif_op_name[] = { > - [BLKIF_OP_READ] = "READ", > - [BLKIF_OP_WRITE] = "WRITE", > -};Looks plausible to me. Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Ian.
Ian Jackson
2012-Apr-02 14:31 UTC
Re: [PATCH 06 of 18] tools/blktap2: fix out of bounds access in block-log.c
Olaf Hering writes ("[Xen-devel] [PATCH 06 of 18] tools/blktap2: fix out of bounds access in block-log.c"):> tools/blktap2: fix out of bounds access in block-log.c > > block-log.c: In function ''ctl_close_sock'': > block-log.c:363:23: warning: array subscript is above array bounds [-Warray-bounds] > > Adjust loop condition in ctl_close_sock() to fix warning. > Adjust array acccess in ctl_close() to actually access the array member.Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Good fix for unpleasant code, thanks. Ian.
Ian Jackson
2012-Apr-02 14:32 UTC
Re: [PATCH 15 of 18] tools/blktap2: remove static string table from header file
Olaf Hering writes ("[Xen-devel] [PATCH 15 of 18] tools/blktap2: remove static string table from header file"):> tools/blktap2: remove static string table from header file > > -O2 -Wall -Werror triggers these warnings: > > ../../include/vhd.h:109: warning: ''HD_TYPE_STR'' defined but not used > > Since its used only in one place, move it to the .c file.Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Jackson
2012-Apr-02 14:32 UTC
Re: [PATCH 17 of 18] tools/blktap2: remove unused labels
Olaf Hering writes ("[Xen-devel] [PATCH 17 of 18] tools/blktap2: remove unused labels"):> tools/blktap2: remove unused labels > > vhd-util-read.c:478:2: warning: label ''print'' defined but not used [-Wunused-label] > vhd-util-set-field.c:99:2: warning: label ''done'' defined but not used [-Wunused-label]Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Jackson
2012-Apr-02 14:33 UTC
Re: [PATCH 14 of 18] tools/libvchan: fix build errors caused by Werror in io.c
Olaf Hering writes ("[Xen-devel] [PATCH 14 of 18] tools/libvchan: fix build errors caused by Werror in io.c"):> tools/libvchan: fix build errors caused by Werror in io.c...> - writev(-1, iov, 2); > + if (writev(-1, iov, 2));You need to actually fix these lost error bugs, not just suppress the warning. Ian.
Olaf Hering
2012-Apr-02 14:37 UTC
Re: [PATCH 14 of 18] tools/libvchan: fix build errors caused by Werror in io.c
On Mon, Apr 02, Ian Jackson wrote:> Olaf Hering writes ("[Xen-devel] [PATCH 14 of 18] tools/libvchan: fix build errors caused by Werror in io.c"): > > tools/libvchan: fix build errors caused by Werror in io.c > ... > > - writev(-1, iov, 2); > > + if (writev(-1, iov, 2)); > > You need to actually fix these lost error bugs, not just suppress the > warning.The others I havent looked at yet, yes. But this write to fd ''-1'' one is just for strace. Olaf
Ian Jackson
2012-Apr-02 14:38 UTC
Re: [PATCH 02 of 18] tools/blktap: fix params and physical-device parsing
Olaf Hering writes ("[Xen-devel] [PATCH 02 of 18] tools/blktap: fix params and physical-device parsing"):> tools/blktap: fix params and physical-device parsing > > If parsing the "physical-device" property fails the physical device node > should come from the "params" property. But since the deverr value was > overwritten during read of the "mode" property, the "params" property > was never parsed.I think this should be fixed by having the read-only check not improperly reuse `deverr''. Ian.
Ian Jackson
2012-Apr-02 14:39 UTC
Re: [PATCH 14 of 18] tools/libvchan: fix build errors caused by Werror in io.c
Olaf Hering writes ("Re: [Xen-devel] [PATCH 14 of 18] tools/libvchan: fix build errors caused by Werror in io.c"):> On Mon, Apr 02, Ian Jackson wrote: > > You need to actually fix these lost error bugs, not just suppress the > > warning. > > The others I havent looked at yet, yes. > But this write to fd ''-1'' one is just for strace.Oh wait I didn''t spot that. That''s insane. I guess you should assert that it always fails, but really why oh why oh why ? Ian.
Ian Jackson
2012-Apr-02 14:39 UTC
Re: [PATCH 12 of 18] tools/memshr: fix build errors caused by Werror
Olaf Hering writes ("[Xen-devel] [PATCH 12 of 18] tools/memshr: fix build errors caused by Werror"):> tools/memshr: fix build errors caused by Werror...> Mark fingerprint functions as inline, remove unused variables.Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Olaf Hering
2012-Apr-02 14:40 UTC
Re: [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c
On Mon, Apr 02, Ian Jackson wrote:> Olaf Hering writes ("[Xen-devel] [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c"): > > tools/libvchan: fix build errors caused by -Werror in node-select.c > > > > -O2 -Wall -Werror triggers these warnings: > > > > node-select.c:57:6: warning: function declaration isn''t a prototype [-Wstrict-prototypes] > > These changes are correct. > > > node-select.c: In function ''vchan_wr'': > > node-select.c:60:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] > > This one is a question of coding style. Apparently libvchan uses > mixed statements/declarations, so this should be fixed by changing the > warning flags.The warning is odd anyway since -std=gnu99 is requested. I will split the patch to address both warnings. Olaf
Olaf Hering
2012-Apr-02 14:42 UTC
Re: [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num
On Mon, Apr 02, Ian Jackson wrote:> The point I was making is that it does not increment (*p).Yes, you are right. Olaf
Olaf Hering
2012-Apr-02 14:44 UTC
Re: [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num
On Mon, Apr 02, Ian Jackson wrote:> Olaf Hering writes ("[Xen-devel] [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num"): > > xs_api.c: In function ''convert_dev_name_to_num'': > ... > > ptr should be increased in each iteration, not the char it points to. > > These changes from `*p++;'' to `p++'' are correct. But the description > is wrong. `*p++'' is the same as `*(p++)'' ie it increments p and then > uselessly dereferences it. > > > - 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"; > > And this hunk seems entirely unexplained. Is it supposed to be a > const-correctness fix ? Stylistic improvement ?I think that part is not strictly needed. Olaf
Ian Campbell
2012-Apr-02 15:04 UTC
Re: [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num
On Mon, 2012-04-02 at 15:44 +0100, Olaf Hering wrote:> On Mon, Apr 02, Ian Jackson wrote: > > > Olaf Hering writes ("[Xen-devel] [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num"): > > > xs_api.c: In function ''convert_dev_name_to_num'': > > ... > > > ptr should be increased in each iteration, not the char it points to. > > > > These changes from `*p++;'' to `p++'' are correct. But the description > > is wrong. `*p++'' is the same as `*(p++)'' ie it increments p and then > > uselessly dereferences it. > > > > > - 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"; > > > > And this hunk seems entirely unexplained. Is it supposed to be a > > const-correctness fix ? Stylistic improvement ? > > I think that part is not strictly needed.Adding the const seems reasonable enough. Not sure what the static buys you on top of that. Ian.
Olaf Hering
2012-Apr-02 15:08 UTC
Re: [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num
On Mon, Apr 02, Ian Campbell wrote:> On Mon, 2012-04-02 at 15:44 +0100, Olaf Hering wrote: > > On Mon, Apr 02, Ian Jackson wrote: > > > > > Olaf Hering writes ("[Xen-devel] [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num"): > > > > xs_api.c: In function ''convert_dev_name_to_num'': > > > ... > > > > ptr should be increased in each iteration, not the char it points to. > > > > > > These changes from `*p++;'' to `p++'' are correct. But the description > > > is wrong. `*p++'' is the same as `*(p++)'' ie it increments p and then > > > uselessly dereferences it. > > > > > > > - 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"; > > > > > > And this hunk seems entirely unexplained. Is it supposed to be a > > > const-correctness fix ? Stylistic improvement ? > > > > I think that part is not strictly needed. > > Adding the const seems reasonable enough. Not sure what the static buys > you on top of that.static is not needed, you are right. I will split that patch. Olaf
Ian Jackson
2012-Apr-02 15:16 UTC
Re: [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num
Ian Campbell writes ("Re: [Xen-devel] [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num"):> On Mon, 2012-04-02 at 15:44 +0100, Olaf Hering wrote: > > On Mon, Apr 02, Ian Jackson wrote: > > > Olaf Hering writes ("[Xen-devel] [PATCH 01 of 18] tools/blktap: fix access errors in convert_dev_name_to_num"):...> > > > - 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"; > > > > > > And this hunk seems entirely unexplained. Is it supposed to be a > > > const-correctness fix ? Stylistic improvement ? > > ... > > I think that part is not strictly needed.Right. But I don''t object to it, if it is properly described in the commit message.> Adding the const seems reasonable enough. Not sure what the static buys > you on top of that.Changing from const char *str = "foo"; to const char str[] = "foo"; prevents erroneous code from modifying str. Ian.
Olaf Hering
2012-Apr-02 19:54 UTC
Re: [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c
On Mon, Apr 02, Ian Jackson wrote:> Olaf Hering writes ("[Xen-devel] [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c"): > > node-select.c: In function ''vchan_wr'': > > node-select.c:60:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] > > This one is a question of coding style. Apparently libvchan uses > mixed statements/declarations, so this should be fixed by changing the > warning flags.This is from xen itself: .. -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement .. Are you saying -Wdeclaration-after-statement should be removed? diff -r 7c29b8723556 Config.mk --- a/Config.mk +++ b/Config.mk @@ -161,7 +161,7 @@ CFLAGS += -Wall -Wstrict-prototypes # and is over-zealous with the printf format lint CFLAGS-$(clang) += -Wno-parentheses -Wno-format -$(call cc-option-add,HOSTCFLAGS,HOSTCC,-Wdeclaration-after-statement) +$(call cc-option-add,HOSTCFLAGS,HOSTCC,-Wno-declaration-after-statement) $(call cc-option-add,CFLAGS,CC,-Wdeclaration-after-statement) $(call cc-option-add,CFLAGS,CC,-Wno-unused-but-set-variable)
Olaf Hering
2012-Apr-02 19:58 UTC
Re: [PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback
On Mon, Apr 02, Ian Jackson wrote:> Olaf Hering writes ("[Xen-devel] [PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback"): > > tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback > > > > -O2 -Wall -Werror triggers these warnings: > > > > libxl.c: In function ''disk_eject_xswatch_callback'': > > libxl.c:928: warning: zero-length printf format string > > There is nothing wrong with zero-length format strings. This warning > should be disabled. Please do send a patch to do so.-Wno-format-zero-length -Wall has no effect, and -Wall comes from RPM_OPT_FLAGS which will come last with my current EXTRA_CFLAGS patch. Olaf
Ian Campbell
2012-Apr-03 08:23 UTC
Re: [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c
On Mon, 2012-04-02 at 20:54 +0100, Olaf Hering wrote:> On Mon, Apr 02, Ian Jackson wrote: > > > Olaf Hering writes ("[Xen-devel] [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c"): > > > node-select.c: In function ''vchan_wr'': > > > node-select.c:60:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] > > > > This one is a question of coding style. Apparently libvchan uses > > mixed statements/declarations, so this should be fixed by changing the > > warning flags. > > This is from xen itself: > > .. -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement .. > > Are you saying -Wdeclaration-after-statement should be removed?No, if appropriate to do so then it should be removed from tools/libvchan like we do in tools/libxl. However skimming over node-select.c and io.c (as another random file) it looks like the use of mixed declarations and code is the exception not the rule even within libvchan, so I think it would be fine to fix the two places where this isn''t the case. Ian.> > diff -r 7c29b8723556 Config.mk > --- a/Config.mk > +++ b/Config.mk > @@ -161,7 +161,7 @@ CFLAGS += -Wall -Wstrict-prototypes > # and is over-zealous with the printf format lint > CFLAGS-$(clang) += -Wno-parentheses -Wno-format > > -$(call cc-option-add,HOSTCFLAGS,HOSTCC,-Wdeclaration-after-statement) > +$(call cc-option-add,HOSTCFLAGS,HOSTCC,-Wno-declaration-after-statement) > $(call cc-option-add,CFLAGS,CC,-Wdeclaration-after-statement) > $(call cc-option-add,CFLAGS,CC,-Wno-unused-but-set-variable) > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
Ian Campbell
2012-Apr-03 08:30 UTC
Re: [PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback
On Mon, 2012-04-02 at 20:58 +0100, Olaf Hering wrote:> On Mon, Apr 02, Ian Jackson wrote: > > > Olaf Hering writes ("[Xen-devel] [PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback"): > > > tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback > > > > > > -O2 -Wall -Werror triggers these warnings: > > > > > > libxl.c: In function ''disk_eject_xswatch_callback'': > > > libxl.c:928: warning: zero-length printf format string > > > > There is nothing wrong with zero-length format strings. This warning > > should be disabled. Please do send a patch to do so. > > -Wno-format-zero-length -Wall has no effect, and -Wall comes from > RPM_OPT_FLAGS which will come last with my current EXTRA_CFLAGS patch.IMHO it''s a little bit unreasonable for RPM to think it knows better than upstream what warning flags are appropriate. Especially given not all the warnings are useful and/or make sense (which is certainly the case for Wformat-zero-length[0]). I''d suggest that RPM_OPT_FLAGS either ought to omit Wno-format-zero-length or, if it is a member of some umbrella -W option, grow a -Wno-format-zero-length. Or if you cannot control RPM_OPT_FLAGS in that way you should pass it alongside RPM_OPT_FLAGS in via EXTRA_CFLAGS. [0] Even gcc(1) says: -Wno-format-zero-length (C and Objective-C only) If -Wformat is specified, do not warn about zero-length formats. The C standard specifies that zero-length formats are allowed. So quite why it appears that Wall is enabling Wformat-zero-length I have no idea, this is a clear gcc bug in my opinion. Ian.
Olaf Hering
2012-Apr-03 09:07 UTC
Re: [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c
On Tue, Apr 03, Ian Campbell wrote:> On Mon, 2012-04-02 at 20:54 +0100, Olaf Hering wrote: > > On Mon, Apr 02, Ian Jackson wrote: > > > > > Olaf Hering writes ("[Xen-devel] [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c"): > > > > node-select.c: In function ''vchan_wr'': > > > > node-select.c:60:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] > > > > > > This one is a question of coding style. Apparently libvchan uses > > > mixed statements/declarations, so this should be fixed by changing the > > > warning flags.> However skimming over node-select.c and io.c (as another random file) it > looks like the use of mixed declarations and code is the exception not > the rule even within libvchan, so I think it would be fine to fix the > two places where this isn''t the case.If thats ok with IanJ as well, I will prepare another patch to fix just that warning in node-select.c Olaf
Olaf Hering
2012-Apr-03 09:11 UTC
Re: [PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback
On Tue, Apr 03, Ian Campbell wrote:> [0] Even gcc(1) says: > -Wno-format-zero-length (C and Objective-C only) > If -Wformat is specified, do not warn about zero-length formats. > The C standard specifies that zero-length formats are allowed. > So quite why it appears that Wall is enabling Wformat-zero-length I have > no idea, this is a clear gcc bug in my opinion.Thats what they say: "<jakub> olaf_: warnings aren''t just about things that aren''t allowed in the standard, but about things considered bad by significant amount of users" So gcc wont be changed. Olaf
Ian Campbell
2012-Apr-03 09:24 UTC
Re: [PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback
On Tue, 2012-04-03 at 10:11 +0100, Olaf Hering wrote:> On Tue, Apr 03, Ian Campbell wrote: > > > [0] Even gcc(1) says: > > -Wno-format-zero-length (C and Objective-C only) > > If -Wformat is specified, do not warn about zero-length formats. > > The C standard specifies that zero-length formats are allowed. > > So quite why it appears that Wall is enabling Wformat-zero-length I have > > no idea, this is a clear gcc bug in my opinion. > > Thats what they say: > > "<jakub> olaf_: warnings aren''t just about things that aren''t allowed in > the standard, but about things considered bad by significant amount of > users"I find it hard to believe that a significant amount of users think this particular warning is worthwhile, since there are clearly legitimate uses of an empty format string (our use in libxl__xs_write being the obvious example!), and as far as I can tell the only argument for it is that it might waste a few precious cycles, but I''ve not got the energy to argue with the gcc developers about it.> So gcc wont be changed.Then we should disable this warning, after our own Wall. If something else (like RPM_OPTS) is also adding Wall then it had better do the same. Ian.
Ian Jackson
2012-Apr-03 10:20 UTC
Re: [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c
Olaf Hering writes ("Re: [Xen-devel] [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c"):> This is from xen itself: > .. -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement ..Yes. That''s the default for code in the Xen tree. But it can be locally overridden. See the libxl Makefile for an example. Ian.
Ian Jackson
2012-Apr-03 10:21 UTC
Re: [PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback
Olaf Hering writes ("Re: [Xen-devel] [PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback"):> On Mon, Apr 02, Ian Jackson wrote: > > There is nothing wrong with zero-length format strings. This warning > > should be disabled. Please do send a patch to do so. > > -Wno-format-zero-length -Wall has no effect, and -Wall comes from > RPM_OPT_FLAGS which will come last with my current EXTRA_CFLAGS patch.Every occurrence of -Wall should have -Wno-format-zero-length appended. There is no reason ever to warn about zero-length format strings and it is a mystery why it''s still the default. Ian.
Ian Jackson
2012-Apr-03 10:27 UTC
Re: [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c
Olaf Hering writes ("Re: [Xen-devel] [PATCH 10 of 18] tools/libvchan: fix build errors caused by -Werror in node-select.c"):> On Tue, Apr 03, Ian Campbell wrote:...> > However skimming over node-select.c and io.c (as another random file) it > > looks like the use of mixed declarations and code is the exception not > > the rule even within libvchan, so I think it would be fine to fix the > > two places where this isn''t the case. > > If thats ok with IanJ as well, I will prepare another patch to fix just > that warning in node-select.cThat''s fine. Ian.
Ian Jackson
2012-Apr-03 10:28 UTC
Re: [PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback
Olaf Hering writes ("Re: [Xen-devel] [PATCH 11 of 18] tools/libxl: fix build errors caused by Werror in disk_eject_xswatch_callback"):> On Tue, Apr 03, Ian Campbell wrote: > > [0] Even gcc(1) says: > > -Wno-format-zero-length (C and Objective-C only) > > If -Wformat is specified, do not warn about zero-length formats. > > The C standard specifies that zero-length formats are allowed. > > So quite why it appears that Wall is enabling Wformat-zero-length I have > > no idea, this is a clear gcc bug in my opinion. > > Thats what they say: > > "<jakub> olaf_: warnings aren''t just about things that aren''t allowed in > the standard, but about things considered bad by significant amount of > users" > > So gcc wont be changed.I haven''t found anyone who can come up with a plausible reason to think that a zero-length format string is wrong. But I don''t want to get into an argument with gcc upstream. The right answer is to disable the warning, wherever it is being enabled. Ian.