diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-02-19 16:59:32 +0100 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-02-19 16:59:32 +0100 |
commit | 24f21473fb493edf7fced3b4f680c99123145014 (patch) | |
tree | f9071bf52a972e0f23dfe31ecfcf9acb92462ba5 /lib/perfdata.c | |
parent | d4274cfdac8125160f43a8098a578eb3077fcda0 (diff) | |
download | monitoring-plugins-24f21473fb493edf7fced3b4f680c99123145014.tar.gz |
Use asprintf in lib directly instead of xasprintf
Diffstat (limited to 'lib/perfdata.c')
-rw-r--r-- | lib/perfdata.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/perfdata.c b/lib/perfdata.c index f894df39..661756c5 100644 --- a/lib/perfdata.c +++ b/lib/perfdata.c | |||
@@ -14,13 +14,13 @@ char *pd_value_to_string(const mp_perfdata_value pd) { | |||
14 | 14 | ||
15 | switch (pd.type) { | 15 | switch (pd.type) { |
16 | case PD_TYPE_INT: | 16 | case PD_TYPE_INT: |
17 | xasprintf(&result, "%lli", pd.pd_int); | 17 | asprintf(&result, "%lli", pd.pd_int); |
18 | break; | 18 | break; |
19 | case PD_TYPE_UINT: | 19 | case PD_TYPE_UINT: |
20 | xasprintf(&result, "%llu", pd.pd_int); | 20 | asprintf(&result, "%llu", pd.pd_int); |
21 | break; | 21 | break; |
22 | case PD_TYPE_DOUBLE: | 22 | case PD_TYPE_DOUBLE: |
23 | xasprintf(&result, "%f", pd.pd_double); | 23 | asprintf(&result, "%f", pd.pd_double); |
24 | break; | 24 | break; |
25 | default: | 25 | default: |
26 | // die here | 26 | // die here |
@@ -33,33 +33,33 @@ char *pd_value_to_string(const mp_perfdata_value pd) { | |||
33 | char *pd_to_string(mp_perfdata pd) { | 33 | char *pd_to_string(mp_perfdata pd) { |
34 | assert(pd.label != NULL); | 34 | assert(pd.label != NULL); |
35 | char *result = NULL; | 35 | char *result = NULL; |
36 | xasprintf(&result, "%s=", pd.label); | 36 | asprintf(&result, "%s=", pd.label); |
37 | 37 | ||
38 | xasprintf(&result, "%s%s", result, pd_value_to_string(pd.value)); | 38 | asprintf(&result, "%s%s", result, pd_value_to_string(pd.value)); |
39 | 39 | ||
40 | if (pd.uom != NULL) { | 40 | if (pd.uom != NULL) { |
41 | xasprintf(&result, "%s%s", result, pd.uom); | 41 | asprintf(&result, "%s%s", result, pd.uom); |
42 | } | 42 | } |
43 | 43 | ||
44 | if (pd.warn_present) { | 44 | if (pd.warn_present) { |
45 | xasprintf(&result, "%s;%s", result, mp_range_to_string(pd.warn)); | 45 | asprintf(&result, "%s;%s", result, mp_range_to_string(pd.warn)); |
46 | } else { | 46 | } else { |
47 | xasprintf(&result, "%s;", result); | 47 | asprintf(&result, "%s;", result); |
48 | } | 48 | } |
49 | 49 | ||
50 | if (pd.crit_present) { | 50 | if (pd.crit_present) { |
51 | xasprintf(&result, "%s;%s", result, mp_range_to_string(pd.crit)); | 51 | asprintf(&result, "%s;%s", result, mp_range_to_string(pd.crit)); |
52 | } else { | 52 | } else { |
53 | xasprintf(&result, "%s;", result); | 53 | asprintf(&result, "%s;", result); |
54 | } | 54 | } |
55 | if (pd.min_present) { | 55 | if (pd.min_present) { |
56 | xasprintf(&result, "%s;%s", result, pd_value_to_string(pd.min)); | 56 | asprintf(&result, "%s;%s", result, pd_value_to_string(pd.min)); |
57 | } else { | 57 | } else { |
58 | xasprintf(&result, "%s;", result); | 58 | asprintf(&result, "%s;", result); |
59 | } | 59 | } |
60 | 60 | ||
61 | if (pd.max_present) { | 61 | if (pd.max_present) { |
62 | xasprintf(&result, "%s;%s", result, pd_value_to_string(pd.max)); | 62 | asprintf(&result, "%s;%s", result, pd_value_to_string(pd.max)); |
63 | } | 63 | } |
64 | 64 | ||
65 | /*printf("pd_to_string: %s\n", result); */ | 65 | /*printf("pd_to_string: %s\n", result); */ |
@@ -71,7 +71,7 @@ char *pd_list_to_string(const pd_list pd) { | |||
71 | char *result = pd_to_string(pd.data); | 71 | char *result = pd_to_string(pd.data); |
72 | 72 | ||
73 | for (pd_list *elem = pd.next; elem != NULL; elem = elem->next) { | 73 | for (pd_list *elem = pd.next; elem != NULL; elem = elem->next) { |
74 | xasprintf(&result, "%s %s", result, pd_to_string(elem->data)); | 74 | asprintf(&result, "%s %s", result, pd_to_string(elem->data)); |
75 | } | 75 | } |
76 | 76 | ||
77 | return result; | 77 | return result; |
@@ -234,17 +234,17 @@ int cmp_perfdata_value(const mp_perfdata_value a, const mp_perfdata_value b) { | |||
234 | char *mp_range_to_string(const mp_range input) { | 234 | char *mp_range_to_string(const mp_range input) { |
235 | char *result = ""; | 235 | char *result = ""; |
236 | if (input.alert_on_inside_range == INSIDE) { | 236 | if (input.alert_on_inside_range == INSIDE) { |
237 | xasprintf(&result, "@"); | 237 | asprintf(&result, "@"); |
238 | } | 238 | } |
239 | 239 | ||
240 | if (input.start_infinity) { | 240 | if (input.start_infinity) { |
241 | xasprintf(&result, "%s~:", result); | 241 | asprintf(&result, "%s~:", result); |
242 | } else { | 242 | } else { |
243 | xasprintf(&result, "%s%s:", result, pd_value_to_string(input.start)); | 243 | asprintf(&result, "%s%s:", result, pd_value_to_string(input.start)); |
244 | } | 244 | } |
245 | 245 | ||
246 | if (!input.end_infinity) { | 246 | if (!input.end_infinity) { |
247 | xasprintf(&result, "%s%s", result, pd_value_to_string(input.end)); | 247 | asprintf(&result, "%s%s", result, pd_value_to_string(input.end)); |
248 | } | 248 | } |
249 | return result; | 249 | return result; |
250 | } | 250 | } |