diff options
author | Mike Christie <michaelc@cs.wisc.edu> | 2009-05-20 18:00:53 -0500 |
---|---|---|
committer | Mike Christie <michaelc@cs.wisc.edu> | 2009-05-20 18:00:53 -0500 |
commit | c19c424e2dadc19c4e32a064a42966e49375b918 (patch) | |
tree | f470d849d876605608df73e431c1965e02b4293a | |
parent | 524175bb14281277a5c8cc419c72c2f38fccdc87 (diff) | |
download | open-iscsi-c19c424e2dadc19c4e32a064a42966e49375b918.tar.gz |
iscsi sysfs: fix compilation warning about unsigned long long cast
uint64_t can be unsigned long long or unsigned long depending on the
arch. This just has us use sscanf with PRIu64 to read in our uint64_t.
-rw-r--r-- | usr/iscsi_sysfs.c | 4 | ||||
-rw-r--r-- | usr/sysfs.c | 10 | ||||
-rw-r--r-- | usr/sysfs.h | 5 |
3 files changed, 9 insertions, 10 deletions
diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c index 0fa83eb..cb9a5a1 100644 --- a/usr/iscsi_sysfs.c +++ b/usr/iscsi_sysfs.c @@ -117,8 +117,8 @@ static int read_transports(void) log_debug(7, "Updating transport %s", namelist[i]->d_name); - if (sysfs_get_ull(t->name, ISCSI_TRANSPORT_SUBSYS, - "handle", (unsigned long long *)&t->handle)) { + if (sysfs_get_uint64(t->name, ISCSI_TRANSPORT_SUBSYS, + "handle", &t->handle)) { if (list_empty(&t->list)) free(t); else diff --git a/usr/sysfs.c b/usr/sysfs.c index 112a73a..7c743e6 100644 --- a/usr/sysfs.c +++ b/usr/sysfs.c @@ -27,6 +27,7 @@ #include <ctype.h> #include <errno.h> #include <limits.h> +#include <inttypes.h> #include <sys/stat.h> #include "log.h" @@ -620,8 +621,7 @@ int sysfs_get_str(char *id, char *subsys, char *param, char *value, return 0; } -int sysfs_get_ull(char *id, char *subsys, char *param, - unsigned long long *value) +int sysfs_get_uint64(char *id, char *subsys, char *param, uint64_t *value) { char *sysfs_value; @@ -630,10 +630,8 @@ int sysfs_get_ull(char *id, char *subsys, char *param, if (!sysfs_value) return EIO; - errno = 0; - *value = strtoull(sysfs_value, NULL, 0); - if (errno) - return errno; + if (sscanf(sysfs_value, "%" PRIu64 "\n", value) != 1) + return EINVAL; return 0; } diff --git a/usr/sysfs.h b/usr/sysfs.h index 67d459d..4c70dbd 100644 --- a/usr/sysfs.h +++ b/usr/sysfs.h @@ -22,6 +22,7 @@ #ifndef _SYSFS_ #define _SYSFS_ +#include <stdint.h> #include "list.h" #include "string.h" @@ -56,8 +57,8 @@ extern int sysfs_get_uint(char *id, char *subsys, char *param, extern int sysfs_get_int(char *id, char *subsys, char *param, int *value); extern int sysfs_get_str(char *id, char *subsys, char *param, char *value, int value_size); -extern int sysfs_get_ull(char *id, char *subsys, char *param, - unsigned long long *value); +extern int sysfs_get_uint64(char *id, char *subsys, char *param, + uint64_t *value); extern int sysfs_set_param(char *id, char *subsys, char *attr_name, char *write_buf, ssize_t buf_size); |