projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #2807 from sileht/master
[collectd.git]
/
src
/
utils_mount.c
diff --git
a/src/utils_mount.c
b/src/utils_mount.c
index
87f26df
..
279f8e2
100644
(file)
--- a/
src/utils_mount.c
+++ b/
src/utils_mount.c
@@
-258,7
+258,7
@@
static void uuidcache_init(void) {
* (This is useful, if the cdrom on /dev/hdc must not
* be accessed.)
*/
* (This is useful, if the cdrom on /dev/hdc must not
* be accessed.)
*/
- s
s
nprintf(device, sizeof(device), "%s/%s", DEVLABELDIR, ptname);
+ snprintf(device, sizeof(device), "%s/%s", DEVLABELDIR, ptname);
if (!get_label_uuid(device, &label, uuid)) {
uuidcache_addentry(sstrdup(device), label, uuid);
}
if (!get_label_uuid(device, &label, uuid)) {
uuidcache_addentry(sstrdup(device), label, uuid);
}
@@
-270,11
+270,11
@@
static void uuidcache_init(void) {
static unsigned char fromhex(char c) {
if (isdigit((int)c)) {
static unsigned char fromhex(char c) {
if (isdigit((int)c)) {
- return
(c - '0')
;
+ return
c - '0'
;
} else if (islower((int)c)) {
} else if (islower((int)c)) {
- return
(c - 'a' + 10)
;
+ return
c - 'a' + 10
;
} else {
} else {
- return
(c - 'A' + 10)
;
+ return
c - 'A' + 10
;
}
}
}
}
@@
-335,7
+335,7
@@
static char *get_device_name(const char *optstr) {
char *rc;
if (optstr == NULL) {
char *rc;
if (optstr == NULL) {
- return
(NULL)
;
+ return
NULL
;
} else if (strncmp(optstr, "UUID=", 5) == 0) {
DEBUG("utils_mount: TODO: check UUID= code!");
rc = get_spec_by_uuid(optstr + 5);
} else if (strncmp(optstr, "UUID=", 5) == 0) {
DEBUG("utils_mount: TODO: check UUID= code!");
rc = get_spec_by_uuid(optstr + 5);
@@
-361,9
+361,7
@@
static cu_mount_t *cu_mount_listmntent(void) {
struct tabmntent *mntlist;
if (listmntent(&mntlist, COLLECTD_MNTTAB, NULL, NULL) < 0) {
#if COLLECT_DEBUG
struct tabmntent *mntlist;
if (listmntent(&mntlist, COLLECTD_MNTTAB, NULL, NULL) < 0) {
#if COLLECT_DEBUG
- char errbuf[1024];
- DEBUG("utils_mount: calling listmntent() failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ DEBUG("utils_mount: calling listmntent() failed: %s", STRERRNO);
#endif /* COLLECT_DEBUG */
}
#endif /* COLLECT_DEBUG */
}
@@
-401,7
+399,7
@@
static cu_mount_t *cu_mount_listmntent(void) {
last->next = NULL;
} /* for(p = mntlist; p; p = p->next) */
last->next = NULL;
} /* for(p = mntlist; p; p = p->next) */
- return
(last)
;
+ return
last
;
} /* cu_mount_t *cu_mount_listmntent(void) */
/* #endif HAVE_LISTMNTENT */
} /* cu_mount_t *cu_mount_listmntent(void) */
/* #endif HAVE_LISTMNTENT */
@@
-431,27
+429,23
@@
static cu_mount_t *cu_mount_getfsstat(void) {
/* Get the number of mounted file systems */
if ((bufsize = CMD_STATFS(NULL, 0, FLAGS_STATFS)) < 1) {
#if COLLECT_DEBUG
/* Get the number of mounted file systems */
if ((bufsize = CMD_STATFS(NULL, 0, FLAGS_STATFS)) < 1) {
#if COLLECT_DEBUG
- char errbuf[1024];
- DEBUG("utils_mount: getv?fsstat failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ DEBUG("utils_mount: getv?fsstat failed: %s", STRERRNO);
#endif /* COLLECT_DEBUG */
#endif /* COLLECT_DEBUG */
- return
(NULL)
;
+ return
NULL
;
}
if ((buf = calloc(bufsize, sizeof(*buf))) == NULL)
}
if ((buf = calloc(bufsize, sizeof(*buf))) == NULL)
- return
(NULL)
;
+ return
NULL
;
/* The bufsize needs to be passed in bytes. Really. This is not in the
* manpage.. -octo */
if ((num = CMD_STATFS(buf, bufsize * sizeof(STRUCT_STATFS), FLAGS_STATFS)) <
1) {
#if COLLECT_DEBUG
/* The bufsize needs to be passed in bytes. Really. This is not in the
* manpage.. -octo */
if ((num = CMD_STATFS(buf, bufsize * sizeof(STRUCT_STATFS), FLAGS_STATFS)) <
1) {
#if COLLECT_DEBUG
- char errbuf[1024];
- DEBUG("utils_mount: getv?fsstat failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ DEBUG("utils_mount: getv?fsstat failed: %s", STRERRNO);
#endif /* COLLECT_DEBUG */
free(buf);
#endif /* COLLECT_DEBUG */
free(buf);
- return
(NULL)
;
+ return
NULL
;
}
for (int i = 0; i < num; i++) {
}
for (int i = 0; i < num; i++) {
@@
-478,7
+472,7
@@
static cu_mount_t *cu_mount_getfsstat(void) {
free(buf);
free(buf);
- return
(first)
;
+ return
first
;
}
/* #endif HAVE_GETVFSSTAT || HAVE_GETFSSTAT */
}
/* #endif HAVE_GETVFSSTAT || HAVE_GETFSSTAT */
@@
-495,10
+489,8
@@
static cu_mount_t *cu_mount_gen_getmntent(void) {
DEBUG("utils_mount: (void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
if ((fp = fopen(COLLECTD_MNTTAB, "r")) == NULL) {
DEBUG("utils_mount: (void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
if ((fp = fopen(COLLECTD_MNTTAB, "r")) == NULL) {
- char errbuf[1024];
- ERROR("fopen (%s): %s", COLLECTD_MNTTAB,
- sstrerror(errno, errbuf, sizeof(errbuf)));
- return (NULL);
+ ERROR("fopen (%s): %s", COLLECTD_MNTTAB, STRERRNO);
+ return NULL;
}
while (getmntent(fp, &mt) == 0) {
}
while (getmntent(fp, &mt) == 0) {
@@
-525,9
+517,8
@@
static cu_mount_t *cu_mount_gen_getmntent(void) {
fclose(fp);
fclose(fp);
- return
(first)
;
+ return
first
;
} /* static cu_mount_t *cu_mount_gen_getmntent (void) */
} /* static cu_mount_t *cu_mount_gen_getmntent (void) */
-/* #endif HAVE_TWO_GETMNTENT || HAVE_GEN_GETMNTENT || HAVE_SUN_GETMNTENT */
#elif HAVE_SEQ_GETMNTENT
#warn "This version of `getmntent' hat not yet been implemented!"
#elif HAVE_SEQ_GETMNTENT
#warn "This version of `getmntent' hat not yet been implemented!"
@@
-546,10
+537,8
@@
static cu_mount_t *cu_mount_getmntent(void) {
DEBUG("utils_mount: (void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
if ((fp = setmntent(COLLECTD_MNTTAB, "r")) == NULL) {
DEBUG("utils_mount: (void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
if ((fp = setmntent(COLLECTD_MNTTAB, "r")) == NULL) {
- char errbuf[1024];
- ERROR("setmntent (%s): %s", COLLECTD_MNTTAB,
- sstrerror(errno, errbuf, sizeof(errbuf)));
- return (NULL);
+ ERROR("setmntent (%s): %s", COLLECTD_MNTTAB, STRERRNO);
+ return NULL;
}
while (getmntent_r(fp, &me, mntbuf, sizeof(mntbuf))) {
}
while (getmntent_r(fp, &me, mntbuf, sizeof(mntbuf))) {
@@
-580,9
+569,9
@@
static cu_mount_t *cu_mount_getmntent(void) {
endmntent(fp);
endmntent(fp);
- DEBUG("utils_mount: return
(0x%p)
", (void *)first);
+ DEBUG("utils_mount: return
0x%p
", (void *)first);
- return
(first)
;
+ return
first
;
} /* HAVE_GETMNTENT_R */
#elif HAVE_ONE_GETMNTENT
} /* HAVE_GETMNTENT_R */
#elif HAVE_ONE_GETMNTENT
@@
-597,10
+586,8
@@
static cu_mount_t *cu_mount_getmntent(void) {
DEBUG("utils_mount: (void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
if ((fp = setmntent(COLLECTD_MNTTAB, "r")) == NULL) {
DEBUG("utils_mount: (void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
if ((fp = setmntent(COLLECTD_MNTTAB, "r")) == NULL) {
- char errbuf[1024];
- ERROR("setmntent (%s): %s", COLLECTD_MNTTAB,
- sstrerror(errno, errbuf, sizeof(errbuf)));
- return (NULL);
+ ERROR("setmntent (%s): %s", COLLECTD_MNTTAB, STRERRNO);
+ return NULL;
}
while ((me = getmntent(fp)) != NULL) {
}
while ((me = getmntent(fp)) != NULL) {
@@
-631,9
+618,9
@@
static cu_mount_t *cu_mount_getmntent(void) {
endmntent(fp);
endmntent(fp);
- DEBUG("utils_mount: return
(0x%p)
", (void *)first);
+ DEBUG("utils_mount: return
0x%p
", (void *)first);
- return
(first)
;
+ return
first
;
}
#endif /* HAVE_ONE_GETMNTENT */
}
#endif /* HAVE_ONE_GETMNTENT */
@@
-647,7
+634,7
@@
cu_mount_t *cu_mount_getlist(cu_mount_t **list) {
cu_mount_t *last = NULL;
if (list == NULL)
cu_mount_t *last = NULL;
if (list == NULL)
- return
(NULL)
;
+ return
NULL
;
if (*list != NULL) {
first = *list;
if (*list != NULL) {
first = *list;
@@
-664,6
+651,8
@@
cu_mount_t *cu_mount_getlist(cu_mount_t **list) {
new = cu_mount_gen_getmntent();
#elif HAVE_SEQ_GETMNTENT
#error "This version of `getmntent' hat not yet been implemented!"
new = cu_mount_gen_getmntent();
#elif HAVE_SEQ_GETMNTENT
#error "This version of `getmntent' hat not yet been implemented!"
+#elif HAVE_GETMNTENT_R
+ new = cu_mount_getmntent();
#elif HAVE_ONE_GETMNTENT
new = cu_mount_getmntent();
#else
#elif HAVE_ONE_GETMNTENT
new = cu_mount_getmntent();
#else
@@
-681,7
+670,7
@@
cu_mount_t *cu_mount_getlist(cu_mount_t **list) {
while ((last != NULL) && (last->next != NULL))
last = last->next;
while ((last != NULL) && (last->next != NULL))
last = last->next;
- return
(last)
;
+ return
last
;
} /* cu_mount_t *cu_mount_getlist(cu_mount_t **list) */
void cu_mount_freelist(cu_mount_t *list) {
} /* cu_mount_t *cu_mount_getlist(cu_mount_t **list) */
void cu_mount_freelist(cu_mount_t *list) {
@@
-701,7
+690,7
@@
void cu_mount_freelist(cu_mount_t *list) {
char *cu_mount_checkoption(char *line, const char *keyword, int full) {
char *line2, *l2, *p1, *p2;
char *cu_mount_checkoption(char *line, const char *keyword, int full) {
char *line2, *l2, *p1, *p2;
-
in
t l;
+
size_
t l;
if (line == NULL || keyword == NULL) {
return NULL;
if (line == NULL || keyword == NULL) {
return NULL;