Commit 2d2fde0d authored by Ed Rodriguez's avatar Ed Rodriguez Committed by Ben Walker
Browse files

log: Use SPDK_ERRLOG in lieu of fprintf(stderr



Change-Id: Ic87d62516324b9c388a932b268714255b15a9a57
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 70f8a8e2
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@

#include "spdk/conf.h"
#include "spdk/string.h"
#include "spdk/log.h"

struct spdk_conf_value {
	struct spdk_conf_value *next;
@@ -262,7 +263,7 @@ append_cf_section(struct spdk_conf *cp, struct spdk_conf_section *sp)

	cp = CHECK_CP_OR_USE_DEFAULT(cp);
	if (cp == NULL) {
		fprintf(stderr, "%s: cp == NULL\n", __func__);
		SPDK_ERRLOG("cp == NULL\n");
		return;
	}

@@ -457,7 +458,7 @@ parse_line(struct spdk_conf *cp, char *lp)

	arg = spdk_str_trim(lp);
	if (arg == NULL) {
		fprintf(stderr, "no section\n");
		SPDK_ERRLOG("no section\n");
		return -1;
	}

@@ -466,7 +467,7 @@ parse_line(struct spdk_conf *cp, char *lp)
		arg++;
		key = spdk_strsepq(&arg, "]");
		if (key == NULL || arg != NULL) {
			fprintf(stderr, "broken section\n");
			SPDK_ERRLOG("broken section\n");
			return -1;
		}
		/* determine section number */
@@ -495,18 +496,18 @@ parse_line(struct spdk_conf *cp, char *lp)
		/* parameters */
		sp = cp->current_section;
		if (sp == NULL) {
			fprintf(stderr, "unknown section\n");
			SPDK_ERRLOG("unknown section\n");
			return -1;
		}
		key = spdk_strsepq(&arg, CF_DELIM);
		if (key == NULL) {
			fprintf(stderr, "broken key\n");
			SPDK_ERRLOG("broken key\n");
			return -1;
		}

		ip = allocate_cf_item();
		if (ip == NULL) {
			fprintf(stderr, "cannot allocate cf item\n");
			SPDK_ERRLOG("cannot allocate cf item\n");
			return -1;
		}
		append_cf_item(sp, ip);
@@ -522,8 +523,7 @@ parse_line(struct spdk_conf *cp, char *lp)
				val = spdk_strsepq(&arg, CF_DELIM);
				vp = allocate_cf_value();
				if (vp == NULL) {
					fprintf(stderr,
						"cannot allocate cf value\n");
					SPDK_ERRLOG("cannot allocate cf value\n");
					return -1;
				}
				append_cf_value(ip, vp);
@@ -611,7 +611,7 @@ spdk_conf_read(struct spdk_conf *cp, const char *file)

	fp = fopen(file, "r");
	if (fp == NULL) {
		fprintf(stderr, "open error: %s\n", file);
		SPDK_ERRLOG("open error: %s\n", file);
		return -1;
	}

@@ -648,7 +648,7 @@ spdk_conf_read(struct spdk_conf *cp, const char *file)
			if (!q) {
				free(lp2);
				free(lp);
				fprintf(stderr, "malloc failed at line %d of %s\n", line, cp->file);
				SPDK_ERRLOG("malloc failed at line %d of %s\n", line, cp->file);
				fclose(fp);
				return -1;
			}
@@ -664,7 +664,7 @@ spdk_conf_read(struct spdk_conf *cp, const char *file)

		/* parse one line */
		if (parse_line(cp, p) < 0) {
			fprintf(stderr, "parse error at line %d of %s\n", line, cp->file);
			SPDK_ERRLOG("parse error at line %d of %s\n", line, cp->file);
		}
next_line:
		line++;
+9 −9
Original line number Diff line number Diff line
@@ -128,12 +128,12 @@ spdk_app_get_running_config(char **config_str, char *name)
	/* Create temporary file to hold config */
	fd = mkstemp(config_template);
	if (fd == -1) {
		fprintf(stderr, "mkstemp failed\n");
		SPDK_ERRLOG("mkstemp failed\n");
		return -1;
	}
	fp = fdopen(fd, "wb+");
	if (NULL == fp) {
		fprintf(stderr, "error opening tmpfile fd = %d\n", fd);
		SPDK_ERRLOG("error opening tmpfile fd = %d\n", fd);
		return -1;
	}

@@ -154,7 +154,7 @@ spdk_app_get_running_config(char **config_str, char *name)
	fseek(fp, 0, SEEK_SET);
	ret = fread(*config_str, sizeof(char), length, fp);
	if (ret < length)
		fprintf(stderr, "%s: warning - short read\n", __func__);
		SPDK_ERRLOG("short read\n");
	fclose(fp);
	(*config_str)[length] = '\0';

@@ -244,12 +244,12 @@ spdk_app_init(struct spdk_app_opts *opts)
	if (opts->config_file) {
		rc = spdk_conf_read(config, opts->config_file);
		if (rc != 0) {
			fprintf(stderr, "Could not read config file %s\n", opts->config_file);
			SPDK_ERRLOG("Could not read config file %s\n", opts->config_file);
			spdk_conf_free(config);
			exit(EXIT_FAILURE);
		}
		if (spdk_conf_first_section(config) == NULL) {
			fprintf(stderr, "Invalid config file %s\n", opts->config_file);
			SPDK_ERRLOG("Invalid config file %s\n", opts->config_file);
			spdk_conf_free(config);
			exit(EXIT_FAILURE);
		}
@@ -272,21 +272,21 @@ spdk_app_init(struct spdk_app_opts *opts)
	if (opts->log_facility == NULL) {
		opts->log_facility = spdk_app_get_log_facility(g_spdk_app.config);
		if (opts->log_facility == NULL) {
			fprintf(stderr, "NULL logfacility\n");
			SPDK_ERRLOG("NULL logfacility\n");
			spdk_conf_free(g_spdk_app.config);
			exit(EXIT_FAILURE);
		}
	}
	rc = spdk_set_log_facility(opts->log_facility);
	if (rc < 0) {
		fprintf(stderr, "log facility error\n");
		SPDK_ERRLOG("log facility error\n");
		spdk_conf_free(g_spdk_app.config);
		exit(EXIT_FAILURE);
	}

	rc = spdk_set_log_priority(SPDK_APP_DEFAULT_LOG_PRIORITY);
	if (rc < 0) {
		fprintf(stderr, "log priority error\n");
		SPDK_ERRLOG("log priority error\n");
		spdk_conf_free(g_spdk_app.config);
		exit(EXIT_FAILURE);
	}
@@ -322,7 +322,7 @@ spdk_app_init(struct spdk_app_opts *opts)
	 *  reactor.
	 */
	if (spdk_reactors_init(opts->max_delay_us)) {
		fprintf(stderr, "Invalid reactor mask.\n");
		SPDK_ERRLOG("Invalid reactor mask.\n");
		spdk_conf_free(g_spdk_app.config);
		exit(EXIT_FAILURE);
	}
+5 −3
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@

#include "spdk/stdinc.h"

#include "spdk/log.h"

#include "spdk_internal/event.h"

static TAILQ_HEAD(spdk_subsystem_list, spdk_subsystem) g_subsystems =
@@ -116,11 +118,11 @@ spdk_subsystem_init(void)
	/* Verify that all dependency name and depends_on subsystems are registered */
	TAILQ_FOREACH(dep, &g_depends, tailq) {
		if (!spdk_subsystem_find(&g_subsystems, dep->name)) {
			fprintf(stderr, "subsystem %s is missing\n", dep->name);
			SPDK_ERRLOG("subsystem %s is missing\n", dep->name);
			return -1;
		}
		if (!spdk_subsystem_find(&g_subsystems, dep->depends_on)) {
			fprintf(stderr, "subsystem %s dependency %s is missing\n",
			SPDK_ERRLOG("subsystem %s dependency %s is missing\n",
				    dep->name, dep->depends_on);
			return -1;
		}
+2 −2
Original line number Diff line number Diff line
@@ -300,12 +300,12 @@ spdk_log_register_trace_flag(const char *name, struct spdk_trace_flag *flag)
	struct spdk_trace_flag *iter;

	if (name == NULL || flag == NULL) {
		fprintf(stderr, "missing spdk_trace_flag parameters\n");
		SPDK_ERRLOG("missing spdk_trace_flag parameters\n");
		abort();
	}

	if (get_trace_flag(name)) {
		fprintf(stderr, "duplicate spdk_trace_flag '%s'\n", name);
		SPDK_ERRLOG("duplicate spdk_trace_flag '%s'\n", name);
		abort();
	}