I have been seeing the following warnings during compilation on arm.
Please find a small patch to address them:
------------------------------------------------------------------------
iscsi/iscsid.c: In function 'iscsi_transportid':
iscsi/iscsid.c:2289: warning: format not a string literal and no format
arguments
iscsi/isns.c: In function 'print_scn_pdu':
iscsi/isns.c:571: warning: format not a string literal and no format
arguments
iscsi/isns.c:571: warning: format not a string literal and no format
arguments
tgtd.c: In function 'run_ext_program':
tgtd.c:292: warning: ignoring return value of 'write', declared with
attribute warn_unused_result
tgtimg.c: In function 'sbc_new':
tgtimg.c:453: warning: ignoring return value of 'pwrite', declared with
attribute warn_unused_result
------------------------------------------------------------------------
Another approach for the last 2 fixes would be of course to check the
return value of write/pwrite.
Regards,
/Pete
>From 82b1837b1452011987d032f8ea01d60f658de27e Mon Sep 17 00:00:00 2001
From: Pete Batard <pbatard@xxxxxxxxx>
Date: Fri, 13 Aug 2010 23:21:43 +0100
Subject: [PATCH] iscsi: fix compilation warnings
"format not a string literal and no format arguments" in s(n)printf
"ignoring return value, declared with warn_unused_result" for (p)write
---
usr/iscsi/iscsid.c | 2 +-
usr/iscsi/isns.c | 2 +-
usr/tgtd.c | 3 ++-
usr/tgtimg.c | 3 ++-
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 3ca98ab..facc999 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -2286,7 +2286,7 @@ static int iscsi_transportid(int tid, uint64_t itn_id, char *buf, int size)
put_unaligned_be16(len - 4, buf + 2);
- sprintf(buf + 4, session->initiator);
+ sprintf(buf + 4, "%s", session->initiator);
p = buf + (4 + strlen(session->initiator) + 1);
diff --git a/usr/iscsi/isns.c b/usr/iscsi/isns.c
index 9ec47e3..69d2ea2 100644
--- a/usr/iscsi/isns.c
+++ b/usr/iscsi/isns.c
@@ -568,7 +568,7 @@ static char *print_scn_pdu(struct isns_hdr *hdr)
case ISNS_ATTR_ISCSI_NAME:
eprintf("scn name: %u, %s\n", vlen, (char *) tlv->value);
if (!name) {
- snprintf(iscsi_name, sizeof(iscsi_name), (char *)tlv->value);
+ snprintf(iscsi_name, sizeof(iscsi_name), "%s", (char *)tlv->value);
name = iscsi_name;
}
break;
diff --git a/usr/tgtd.c b/usr/tgtd.c
index bca6bae..1439f97 100644
--- a/usr/tgtd.c
+++ b/usr/tgtd.c
@@ -265,6 +265,7 @@ int run_ext_program(const char *cmd,
pid_t pid;
int fds[2], ret;
struct ext_prog_info *ex;
+ ssize_t ignored;
ex = zalloc(sizeof(*ex));
if (!ex)
@@ -289,7 +290,7 @@ int run_ext_program(const char *cmd,
if (!pid) {
ret = system(cmd);
- write(fds[1], &ret, sizeof(ret));
+ ignored = write(fds[1], &ret, sizeof(ret));
return 0;
}
diff --git a/usr/tgtimg.c b/usr/tgtimg.c
index 4349fff..70a823b 100644
--- a/usr/tgtimg.c
+++ b/usr/tgtimg.c
@@ -427,6 +427,7 @@ static int mmc_ops(int op, char *path, char *media_type)
static int sbc_new(int op, char *path, char *capacity, char *media_type)
{
int fd;
+ ssize_t ignored;
if (!strncasecmp("disk", media_type, 4)) {
uint32_t pos, size;
@@ -450,7 +451,7 @@ static int sbc_new(int op, char *path, char *capacity, char *media_type)
}
for (pos = 0; pos < size; pos++)
- pwrite(fd, buf, 1024*1024, pos*1024*1024LL);
+ ignored = pwrite(fd, buf, 1024*1024, pos*1024*1024LL);
free(buf);
close(fd);
--
1.7.1.msysgit.0