diff options
| author | waja <waja@users.noreply.github.com> | 2023-06-28 16:39:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-28 16:39:27 +0200 |
| commit | 265a7c0ed8ccde7868bb7e77c44aecc403743c21 (patch) | |
| tree | 3a02f6ce03e8f781dcfca22ee1f17817225a0ff9 /lib | |
| parent | b96a8424f0ec6206238b650c2c63b4bd006ab43a (diff) | |
| parent | b24eb7f46ac8667324efd818c01d68d5a1376c89 (diff) | |
| download | monitoring-plugins-265a7c0.tar.gz | |
Merge branch 'master' into compiler_warning_part_2
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/utils_base.c | 8 | ||||
| -rw-r--r-- | lib/utils_disk.c | 17 |
2 files changed, 13 insertions, 12 deletions
diff --git a/lib/utils_base.c b/lib/utils_base.c index eb1823bb..c458cf61 100644 --- a/lib/utils_base.c +++ b/lib/utils_base.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | * | 24 | * |
| 25 | *****************************************************************************/ | 25 | *****************************************************************************/ |
| 26 | 26 | ||
| 27 | #include "common.h" | 27 | #include "../plugins/common.h" |
| 28 | #include <stdarg.h> | 28 | #include <stdarg.h> |
| 29 | #include "utils_base.h" | 29 | #include "utils_base.h" |
| 30 | #include <ctype.h> | 30 | #include <ctype.h> |
| @@ -319,18 +319,18 @@ char *np_extract_value(const char *varlist, const char *name, char sep) { | |||
| 319 | 319 | ||
| 320 | while (1) { | 320 | while (1) { |
| 321 | /* Strip any leading space */ | 321 | /* Strip any leading space */ |
| 322 | for (varlist; isspace(varlist[0]); varlist++); | 322 | for (; isspace(varlist[0]); varlist++); |
| 323 | 323 | ||
| 324 | if (strncmp(name, varlist, strlen(name)) == 0) { | 324 | if (strncmp(name, varlist, strlen(name)) == 0) { |
| 325 | varlist += strlen(name); | 325 | varlist += strlen(name); |
| 326 | /* strip trailing spaces */ | 326 | /* strip trailing spaces */ |
| 327 | for (varlist; isspace(varlist[0]); varlist++); | 327 | for (; isspace(varlist[0]); varlist++); |
| 328 | 328 | ||
| 329 | if (varlist[0] == '=') { | 329 | if (varlist[0] == '=') { |
| 330 | /* We matched the key, go past the = sign */ | 330 | /* We matched the key, go past the = sign */ |
| 331 | varlist++; | 331 | varlist++; |
| 332 | /* strip leading spaces */ | 332 | /* strip leading spaces */ |
| 333 | for (varlist; isspace(varlist[0]); varlist++); | 333 | for (; isspace(varlist[0]); varlist++); |
| 334 | 334 | ||
| 335 | if (tmp = index(varlist, sep)) { | 335 | if (tmp = index(varlist, sep)) { |
| 336 | /* Value is delimited by a comma */ | 336 | /* Value is delimited by a comma */ |
diff --git a/lib/utils_disk.c b/lib/utils_disk.c index 468769b1..582d3ea1 100644 --- a/lib/utils_disk.c +++ b/lib/utils_disk.c | |||
| @@ -147,24 +147,25 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list | |||
| 147 | 147 | ||
| 148 | /* set best match if path name exactly matches a mounted device name */ | 148 | /* set best match if path name exactly matches a mounted device name */ |
| 149 | for (me = mount_list; me; me = me->me_next) { | 149 | for (me = mount_list; me; me = me->me_next) { |
| 150 | if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0) | 150 | if (strcmp(me->me_devname, d->name)==0) { |
| 151 | continue; /* skip if permissions do not suffice for accessing device */ | 151 | if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) { |
| 152 | if (strcmp(me->me_devname, d->name)==0) | 152 | best_match = me; |
| 153 | best_match = me; | 153 | } |
| 154 | } | ||
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | /* set best match by directory name if no match was found by devname */ | 157 | /* set best match by directory name if no match was found by devname */ |
| 157 | if (! best_match) { | 158 | if (! best_match) { |
| 158 | for (me = mount_list; me; me = me->me_next) { | 159 | for (me = mount_list; me; me = me->me_next) { |
| 159 | if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0) | ||
| 160 | continue; /* skip if permissions do not suffice for accessing device */ | ||
| 161 | size_t len = strlen (me->me_mountdir); | 160 | size_t len = strlen (me->me_mountdir); |
| 162 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && | 161 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && |
| 163 | (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) | 162 | (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) |
| 164 | || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0)) | 163 | || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0)) |
| 165 | { | 164 | { |
| 166 | best_match = me; | 165 | if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) { |
| 167 | best_match_len = len; | 166 | best_match = me; |
| 167 | best_match_len = len; | ||
| 168 | } | ||
| 168 | } | 169 | } |
| 169 | } | 170 | } |
| 170 | } | 171 | } |
