diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-11-16 14:26:41 +0100 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-11-16 14:26:41 +0100 |
| commit | 7bfb16e0da721dcf50558f9104d3ed84efe03516 (patch) | |
| tree | b04570308ac12cb1c1831c54be027a3a5cfc4d57 /plugins/runcmd.c | |
| parent | 2510d9ad5851c669ace7cfc16ea3ff9bf2c86106 (diff) | |
| download | monitoring-plugins-7bfb16e0da721dcf50558f9104d3ed84efe03516.tar.gz | |
Implement replacement functions for executing commands
This commit implements replacement functions for the previous
exec functions.
The replacements are implemented in a more "pure" style, the do no
longer receive pointer arguments which they will write to, but create
the pointers themselves and should therefore be easier to use,
since it is more obvious what goes in and what comes out.
Also a essentialy unused variable was removed with this.
Diffstat (limited to 'plugins/runcmd.c')
| -rw-r--r-- | plugins/runcmd.c | 5 |
1 files changed, 0 insertions, 5 deletions
diff --git a/plugins/runcmd.c b/plugins/runcmd.c index 7c583b85..be6691d2 100644 --- a/plugins/runcmd.c +++ b/plugins/runcmd.c | |||
| @@ -300,7 +300,6 @@ static int np_fetch_output(int fd, output *op, int flags) { | |||
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | op->line = NULL; | 302 | op->line = NULL; |
| 303 | op->lens = NULL; | ||
| 304 | i = 0; | 303 | i = 0; |
| 305 | while (i < op->buflen) { | 304 | while (i < op->buflen) { |
| 306 | /* make sure we have enough memory */ | 305 | /* make sure we have enough memory */ |
| @@ -311,7 +310,6 @@ static int np_fetch_output(int fd, output *op, int flags) { | |||
| 311 | } while (!ary_size); | 310 | } while (!ary_size); |
| 312 | 311 | ||
| 313 | op->line = realloc(op->line, ary_size * sizeof(char *)); | 312 | op->line = realloc(op->line, ary_size * sizeof(char *)); |
| 314 | op->lens = realloc(op->lens, ary_size * sizeof(size_t)); | ||
| 315 | } | 313 | } |
| 316 | 314 | ||
| 317 | /* set the pointer to the string */ | 315 | /* set the pointer to the string */ |
| @@ -323,9 +321,6 @@ static int np_fetch_output(int fd, output *op, int flags) { | |||
| 323 | } | 321 | } |
| 324 | buf[i] = '\0'; | 322 | buf[i] = '\0'; |
| 325 | 323 | ||
| 326 | /* calculate the string length using pointer difference */ | ||
| 327 | op->lens[lineno] = (size_t)&buf[i] - (size_t)op->line[lineno]; | ||
| 328 | |||
| 329 | lineno++; | 324 | lineno++; |
| 330 | i++; | 325 | i++; |
| 331 | } | 326 | } |
