va_start(ap, v);
if (vasprintf(&value, v, ap) < 0)
- value = NULL;
+ value = "Could not allocate string";
- if (value)
- obj_add_str(o, "Result", value);
- else
- obj_add_str(o, "Result", "Could not allocate string");
+ obj_add_str(o, "Result", value);
va_end(ap);
}
va_start(ap, v);
if (vasprintf(&value, v, ap) < 0)
- value = NULL;
+ value = "Could not allocate string";
- if (value)
- obj_add_str(o, k, value);
- else
- obj_add_str(o, k, "Could not allocate string");
+ obj_add_str(o, k, value);
va_end(ap);
}
_cleanup_free_ char *value = NULL;
if (vasprintf(&value, msg, ap) < 0)
- value = NULL;
+ value = "Could not allocate string";
- sprintf(json_str, "Error: %s", value ? value : "Could not allocate string");
+ sprintf(json_str, "Error: %s", value);
r = obj_create(json_str);
if (status < 0) {
_cleanup_free_ char *value = NULL;
if (vasprintf(&value, msg, ap) < 0)
- value = NULL;
+ value = "Could not allocate string";
- obj_add_str(r, error ? "error" : "result", value ? value : "Could not allocate string");
+ obj_add_str(r, error ? "error" : "result", value);
obj_print(r);
}
_cleanup_free_ char *error = NULL;
if (asprintf(&error, "%s: %s", msg, strerror(errno)) < 0)
- error = NULL;
+ error = "Could not allocate string";
- if (error)
- obj_add_str(r, "error", error);
- else
- obj_add_str(r, "error", "Could not allocate string");
+ obj_add_str(r, "error", error);
json_output_object(r);
}