diff options
author | Slava Shwartsman <slavash@FreeBSD.org> | 2018-12-05 13:28:17 +0000 |
---|---|---|
committer | Slava Shwartsman <slavash@FreeBSD.org> | 2018-12-05 13:28:17 +0000 |
commit | a6578a04e440f79f3b913660221caa9cde3e722c (patch) | |
tree | 118912a0efa7bed14df471d4327dba25ed1492bd | |
parent | 3006180863499fff350d385f6d342d0dfab866ef (diff) | |
download | src-test2-a6578a04e440f79f3b913660221caa9cde3e722c.tar.gz src-test2-a6578a04e440f79f3b913660221caa9cde3e722c.zip |
Notes
-rw-r--r-- | contrib/ofed/libibverbs/sysfs.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/contrib/ofed/libibverbs/sysfs.c b/contrib/ofed/libibverbs/sysfs.c index 0ea19fc8fd85..99ccded3276d 100644 --- a/contrib/ofed/libibverbs/sysfs.c +++ b/contrib/ofed/libibverbs/sysfs.c @@ -79,7 +79,7 @@ int ibv_read_sysfs_file(const char *dir, const char *file, char *buf, size_t size) { char *path, *s; - int fd; + int ret; size_t len; if (asprintf(&path, "%s/%s", dir, file) < 0) @@ -89,12 +89,13 @@ int ibv_read_sysfs_file(const char *dir, const char *file, if (*s == '/') *s = '.'; - len = size; - if (sysctlbyname(&path[1], buf, &len, NULL, 0) == -1) - return -1; - + len = size; + ret = sysctlbyname(&path[1], buf, &len, NULL, 0); free(path); + if (ret == -1) + return -1; + if (len > 0 && buf[len - 1] == '\n') buf[--len] = '\0'; |