summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/output.c2
-rw-r--r--lib/parse_ini.c8
-rw-r--r--lib/utils_cmd.c12
-rw-r--r--lib/utils_cmd.h4
4 files changed, 14 insertions, 12 deletions
diff --git a/lib/output.c b/lib/output.c
index f283969f..62e1366d 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -42,7 +42,7 @@ static inline char *fmt_subcheck_perfdata(mp_subcheck check) {
42 42
43 while (subchecks != NULL) { 43 while (subchecks != NULL) {
44 if (added > 0) { 44 if (added > 0) {
45 added = asprintf(&result, "%s%s", result, fmt_subcheck_perfdata(subchecks->subcheck)); 45 added = asprintf(&result, "%s %s", result, fmt_subcheck_perfdata(subchecks->subcheck));
46 } else { 46 } else {
47 // TODO free previous result here? 47 // TODO free previous result here?
48 added = asprintf(&result, "%s", fmt_subcheck_perfdata(subchecks->subcheck)); 48 added = asprintf(&result, "%s", fmt_subcheck_perfdata(subchecks->subcheck));
diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index db337622..196cac79 100644
--- a/lib/parse_ini.c
+++ b/lib/parse_ini.c
@@ -352,15 +352,17 @@ static int add_option(FILE *filePointer, np_arg_list **optlst) {
352 optnew->next = NULL; 352 optnew->next = NULL;
353 353
354 read_pos = 0; 354 read_pos = 0;
355 optnew->arg = malloc(cfg_len + 1); 355 size_t arg_length = cfg_len + 1;
356 optnew->arg = malloc(arg_length);
356 /* 1-character params needs only one dash */ 357 /* 1-character params needs only one dash */
357 if (opt_len == 1) { 358 if (opt_len == 1) {
358 strncpy(&optnew->arg[read_pos], "-", 1); 359 strncpy(&optnew->arg[read_pos], "-", arg_length);
359 read_pos += 1; 360 read_pos += 1;
360 } else { 361 } else {
361 strncpy(&optnew->arg[read_pos], "--", 2); 362 strncpy(&optnew->arg[read_pos], "--", arg_length);
362 read_pos += 2; 363 read_pos += 2;
363 } 364 }
365
364 strncpy(&optnew->arg[read_pos], optptr, opt_len); 366 strncpy(&optnew->arg[read_pos], optptr, opt_len);
365 read_pos += opt_len; 367 read_pos += opt_len;
366 if (value) { 368 if (value) {
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index 42c81793..23d42168 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -489,14 +489,14 @@ cmd_run_result cmd_run2(const char *cmd_string, int flags) {
489 cmd_run_result result = { 489 cmd_run_result result = {
490 .cmd_error_code = 0, 490 .cmd_error_code = 0,
491 .error_code = 0, 491 .error_code = 0,
492 .stderr = 492 .err =
493 { 493 {
494 .buf = NULL, 494 .buf = NULL,
495 .buflen = 0, 495 .buflen = 0,
496 .line = NULL, 496 .line = NULL,
497 .lines = 0, 497 .lines = 0,
498 }, 498 },
499 .stdout = 499 .out =
500 { 500 {
501 .buf = NULL, 501 .buf = NULL,
502 .buflen = 0, 502 .buflen = 0,
@@ -581,14 +581,14 @@ cmd_run_result cmd_run_array2(char *const *cmd, int flags) {
581 cmd_run_result result = { 581 cmd_run_result result = {
582 .cmd_error_code = 0, 582 .cmd_error_code = 0,
583 .error_code = 0, 583 .error_code = 0,
584 .stderr = 584 .err =
585 { 585 {
586 .buf = NULL, 586 .buf = NULL,
587 .buflen = 0, 587 .buflen = 0,
588 .line = NULL, 588 .line = NULL,
589 .lines = 0, 589 .lines = 0,
590 }, 590 },
591 .stdout = 591 .out =
592 { 592 {
593 .buf = NULL, 593 .buf = NULL,
594 .buflen = 0, 594 .buflen = 0,
@@ -610,9 +610,9 @@ cmd_run_result cmd_run_array2(char *const *cmd, int flags) {
610 int pfd_err[2] = {cmd_open_result.stderr_pipe_fd[0], cmd_open_result.stderr_pipe_fd[1]}; 610 int pfd_err[2] = {cmd_open_result.stderr_pipe_fd[0], cmd_open_result.stderr_pipe_fd[1]};
611 611
612 int_cmd_fetch_output2 tmp_stdout = _cmd_fetch_output2(pfd_out[0], flags); 612 int_cmd_fetch_output2 tmp_stdout = _cmd_fetch_output2(pfd_out[0], flags);
613 result.stdout = tmp_stdout.output_container; 613 result.out = tmp_stdout.output_container;
614 int_cmd_fetch_output2 tmp_stderr = _cmd_fetch_output2(pfd_err[0], flags); 614 int_cmd_fetch_output2 tmp_stderr = _cmd_fetch_output2(pfd_err[0], flags);
615 result.stderr = tmp_stderr.output_container; 615 result.err = tmp_stderr.output_container;
616 616
617 result.cmd_error_code = _cmd_close(file_descriptor); 617 result.cmd_error_code = _cmd_close(file_descriptor);
618 return result; 618 return result;
diff --git a/lib/utils_cmd.h b/lib/utils_cmd.h
index d3a8f14f..04a624b8 100644
--- a/lib/utils_cmd.h
+++ b/lib/utils_cmd.h
@@ -24,8 +24,8 @@ int cmd_file_read(const char *, output *, int);
24typedef struct { 24typedef struct {
25 int error_code; 25 int error_code;
26 int cmd_error_code; 26 int cmd_error_code;
27 output stdout; 27 output out;
28 output stderr; 28 output err;
29} cmd_run_result; 29} cmd_run_result;
30cmd_run_result cmd_run2(const char *cmd, int flags); 30cmd_run_result cmd_run2(const char *cmd, int flags);
31cmd_run_result cmd_run_array2(char * const *cmd, int flags); 31cmd_run_result cmd_run_array2(char * const *cmd, int flags);