va_start(ap, v);
if (vasprintf(&value, v, ap) < 0)
- value = "Could not allocate string";
+ value = alloc_error;
obj_add_str(o, "Result", value);
va_start(ap, v);
if (vasprintf(&value, v, ap) < 0)
- value = "Could not allocate string";
+ value = alloc_error;
obj_add_str(o, k, value);
_cleanup_free_ char *value = NULL;
if (vasprintf(&value, msg, ap) < 0)
- value = "Could not allocate string";
+ value = alloc_error;
sprintf(json_str, "Error: %s", value);
r = obj_create(json_str);
_cleanup_free_ char *value = NULL;
if (vasprintf(&value, msg, ap) < 0)
- value = "Could not allocate string";
+ value = alloc_error;
obj_add_str(r, error ? "error" : "result", value);
_cleanup_free_ char *error = NULL;
if (vasprintf(&error, msg, ap) < 0)
- error = "Could not allocate string";
+ error = alloc_error;
obj_add_key(r, "error", "%s: %s", error, strerror(errno));
#define nvme_print_output_format(name, ...) \
nvme_print(name, nvme_is_output_format_json() ? JSON : NORMAL, ##__VA_ARGS__);
+char *alloc_error = "Could not allocate string";
+
static struct print_ops *nvme_print_ops(nvme_print_flags_t flags)
{
struct print_ops *ops = NULL;
void nvme_show_ave_discovery_log(struct nvme_ave_discover_log *log, nvme_print_flags_t flags);
void nvme_show_pull_model_ddc_req_log(struct nvme_pull_model_ddc_req_log *log,
nvme_print_flags_t flags);
+
+extern char *alloc_error;
#endif /* NVME_PRINT_H */