Skip to contentSkip to conversation

pseudo_util: Change pseudo_diag() calls to appropriate logging macros

PATCH New [email protected] 1 participant 8 messages Jun 10

lore
Share & tools
lore
#0 lore raw

PATCH 1/8 pseudo_util: Change pseudo_diag() calls to appropriate logging macros

From: Dmitry Sakhonchik <[email protected]>

The patch is based on: [pseudo] pseudo: Add new logging macros and implements [YOCTO #12141]

---
 pseudo_util.c | 88 +++++++++++++++++++++++++--------------------------
 1 file changed, 44 insertions(+), 44 deletions(-)
pseudo_util.c +44 -44
index f8f2a2f..dbd979e 100644
@@ -177,7 +177,7 @@ pseudo_get_value(const char *key) {
 		value = NULL;
 
 	if (!pseudo_env[i].key) 
-		pseudo_diag("Unknown variable %s.\n", key);
+		pseudo_warning("Unknown variable %s.\n", key);
 
 	return value;
 }
@@ -202,12 +202,12 @@ pseudo_set_value(const char *key, const char *value) {
 			if (new)
 				pseudo_env[i].value = new;
 			else
-				pseudo_diag("warning: failed to save new value (%s) for key %s\n",
+				pseudo_warning("failed to save new value (%s) for key %s\n",
 					value, key);
 		} else
 			pseudo_env[i].value = NULL;
 	} else {
-		if (!pseudo_util_initted) pseudo_diag("Unknown variable %s.\n", key);
+		if (!pseudo_util_initted) pseudo_warning("Unknown variable %s.\n", key);
 		rc = -EINVAL;
 	}
 
@@ -350,7 +350,7 @@ without_libpseudo(char *list) {
 	}
 	list = strdup(list);
 	if (!list) {
-		pseudo_diag("Couldn't allocate memory to remove libpseudo from environment.\n");
+		pseudo_error("Couldn't allocate memory to remove libpseudo from environment.\n");
 	}
 	while (list && !(*real_regexec)(&libpseudo_regex, list, 1, pmatch, 0)) {
 		char *start = list + pmatch[0].rm_so;
@@ -360,7 +360,7 @@ without_libpseudo(char *list) {
 		memmove(start, end, strlen(end) + 1);
 		++counter;
 		if (counter > 5) {
-			pseudo_diag("Found way too many libpseudo.so in environment, giving up.\n");
+			pseudo_error("Found way too many libpseudo.so in environment, giving up.\n");
 			return list;
 		}
 	}
@@ -621,7 +621,7 @@ pseudo_evlog_internal(char *fmt, ...) {
 				event_log[i].data = pseudo_evlog_buffer + (PSEUDO_EVLOG_LENGTH * i);
 			}
 		} else {
-			pseudo_diag("fatal: can't allocate event log storage.\n");
+			pseudo_error("can't allocate event log storage.\n");
 		}
 	}
 
@@ -668,7 +668,7 @@ pseudo_append_element(char *newpath, char *root, size_t allocated, char **pcurre
 	if (!newpath ||
 	    !pcurrent || !*pcurrent ||
 	    !root || !element) {
-		pseudo_diag("pseudo_append_element: invalid args.\n");
+		pseudo_warning("pseudo_append_element: invalid args.\n");
 		return -1;
 	}
 
@@ -689,7 +689,7 @@ pseudo_append_element(char *newpath, char *root, size_t allocated, char **pcurre
 		 * fall through and do standard processing
 		 */
 		if (!proc_path)
-			pseudo_diag("allocation failed seeking memory for path (%s).\n", newpath);
+			pseudo_warning("allocation failed seeking memory for path (%s).\n", newpath);
 		else
 			is_proc = 1;
 	}
@@ -729,7 +729,7 @@ pseudo_append_element(char *newpath, char *root, size_t allocated, char **pcurre
 	/* current length, plus / <element> / \0 */
 	/* => curlen + elen + 3 */
 	if (curlen + elen + 3 > allocated) {
-		pseudo_diag("pseudo_append_element: path too long (wanted %lu bytes).\n", (unsigned long) curlen + elen + 3);
+		pseudo_error("pseudo_append_element: path too long (wanted %lu bytes).\n", (unsigned long) curlen + elen + 3);
 		return -1;
 	}
 	/* append a slash */
@@ -798,7 +798,7 @@ pseudo_append_element(char *newpath, char *root, size_t allocated, char **pcurre
 					char *target_link_path = malloc(pseudo_path_max());
 
 					if (!target_link_path)
-						pseudo_diag("allocation failed seeking memory for path (%s/%s).\n", proc_path, linkbuf);
+						pseudo_error("allocation failed seeking memory for path (%s/%s).\n", proc_path, linkbuf);
 						/* Fall through, nothing we can do here */
 					else {
 						snprintf(target_link_path, target_link_max, "%s/%s", proc_path, linkbuf);
@@ -865,7 +865,7 @@ pseudo_append_elements(char *newpath, char *root, size_t allocated, char **curre
 	if (!newpath || !root ||
 	    !current || !*current ||
 	    !path) {
-		pseudo_diag("pseudo_append_elements: invalid arguments.");
+		pseudo_error("pseudo_append_elements: invalid arguments.");
 		return -1;
 	}
 	if (!sbuf) {
@@ -935,7 +935,7 @@ pseudo_fix_path(const char *base, const char *path, size_t rootlen, size_t basel
 	int trailing_slash = 0;
 	
 	if (!path) {
-		pseudo_diag("can't fix empty path.\n");
+		pseudo_warning("can't fix empty path.\n");
 		return 0;
 	}
 	if (baselen == 1) {
@@ -957,7 +957,7 @@ pseudo_fix_path(const char *base, const char *path, size_t rootlen, size_t basel
 	if (!pathbufs[pathbuf]) {
 		pathbufs[pathbuf] = malloc(newpathlen);
 		if (!pathbufs[pathbuf]) {
-			pseudo_diag("allocation failed seeking memory for path (%s).\n", path);
+			pseudo_error("allocation failed seeking memory for path (%s).\n", path);
 			return 0;
 		}
 	}
@@ -976,7 +976,7 @@ pseudo_fix_path(const char *base, const char *path, size_t rootlen, size_t basel
 	 * easier for the library.
 	 */
 	if (!newpath) {
-		pseudo_diag("allocation failed seeking memory for path (%s).\n", path);
+		pseudo_error("allocation failed seeking memory for path (%s).\n", path);
 		return 0;
 	}
 	newpath[0] = '\0';
@@ -1037,7 +1037,7 @@ void pseudo_dropenv() {
 	if (ld_preload) {
 		ld_preload = without_libpseudo(ld_preload);
 		if (!ld_preload) {
-			pseudo_diag("fatal: can't allocate new %s variable.\n", PRELINK_LIBRARIES);
+			pseudo_error("can't allocate new %s variable.\n", PRELINK_LIBRARIES);
 		}
 		if (ld_preload && strlen(ld_preload)) {
 			SETENV(PRELINK_LIBRARIES, ld_preload, 1);
@@ -1056,7 +1056,7 @@ pseudo_dropenvp(char * const *envp) {
 
 	new_envp = malloc((i + 1) * sizeof(*new_envp));
 	if (!new_envp) {
-		pseudo_diag("fatal: can't allocate new environment.\n");
+		pseudo_error("can't allocate new environment.\n");
 		return NULL;
 	}
 
@@ -1065,7 +1065,7 @@ pseudo_dropenvp(char * const *envp) {
 		if (STARTSWITH(envp[i], PRELINK_LIBRARIES "=")) {
 			char *new_val = without_libpseudo(envp[i]);
 			if (!new_val) {
-				pseudo_diag("fatal: can't allocate new environment variable.\n");
+				pseudo_error("can't allocate new environment variable.\n");
 				return 0;
 			} else {
 				/* don't keep an empty value; if the whole string is
@@ -1111,7 +1111,7 @@ pseudo_setupenv() {
 		size_t len = strlen(libdir_path) + 1 + (strlen(libdir_path) + 2) + 1;
 		char *newenv = malloc(len);
 		if (!newenv) {
-			pseudo_diag("fatal: can't allocate new %s variable.\n", PRELINK_PATH);
+			pseudo_error("can't allocate new %s variable.\n", PRELINK_PATH);
 		} else {
 		    snprintf(newenv, len, "%s:%s64", libdir_path, libdir_path);
 		    SETENV(PRELINK_PATH, newenv, 1);
@@ -1121,7 +1121,7 @@ pseudo_setupenv() {
 		size_t len = strlen(ld_library_path) + 1 + strlen(libdir_path) + 1 + (strlen(libdir_path) + 2) + 1;
 		char *newenv = malloc(len);
 		if (!newenv) {
-			pseudo_diag("fatal: can't allocate new %s variable.\n", PRELINK_PATH);
+			pseudo_error("can't allocate new %s variable.\n", PRELINK_PATH);
 		} else {
 		    snprintf(newenv, len, "%s:%s:%s64", ld_library_path, libdir_path, libdir_path);
 		    SETENV(PRELINK_PATH, newenv, 1);
@@ -1136,7 +1136,7 @@ pseudo_setupenv() {
 	if (ld_preload) {
 		ld_preload = with_libpseudo(ld_preload, libdir_path);
 		if (!ld_preload) {
-			pseudo_diag("fatal: can't allocate new %s variable.\n", PRELINK_LIBRARIES);
+			pseudo_error("can't allocate new %s variable.\n", PRELINK_LIBRARIES);
 		} else {
 		    SETENV(PRELINK_LIBRARIES, ld_preload, 1);
 		    free(ld_preload);
@@ -1144,7 +1144,7 @@ pseudo_setupenv() {
 	} else {
 		ld_preload = with_libpseudo("", libdir_path);
 		if (!ld_preload) {
-			pseudo_diag("fatal: can't allocate new %s variable.\n", PRELINK_LIBRARIES);
+			pseudo_error("can't allocate new %s variable.\n", PRELINK_LIBRARIES);
 		} else {
 		    SETENV(PRELINK_LIBRARIES, ld_preload, 1);
 		    free(ld_preload);
@@ -1216,7 +1216,7 @@ pseudo_setupenvp(char * const *envp) {
 	j = 0;
 	new_envp = malloc((env_count + 1) * sizeof(*new_envp));
 	if (!new_envp) {
-		pseudo_diag("fatal: can't allocate new environment.\n");
+		pseudo_error("can't allocate new environment.\n");
 		return NULL;
 	}	
 
@@ -1225,7 +1225,7 @@ pseudo_setupenvp(char * const *envp) {
 		size_t len = strlen(PRELINK_PATH "=") + strlen(libdir_path) + 1 + (strlen(libdir_path) + 2) + 1;
 		char *newenv = malloc(len);
 		if (!newenv) {
-			pseudo_diag("fatal: can't allocate new %s variable.\n", PRELINK_PATH);
+			pseudo_error("can't allocate new %s variable.\n", PRELINK_PATH);
 		} else {
 		    snprintf(newenv, len, PRELINK_PATH "=%s:%s64", libdir_path, libdir_path);
 		    new_envp[j++] = newenv;
@@ -1234,7 +1234,7 @@ pseudo_setupenvp(char * const *envp) {
 		size_t len = strlen(ld_library_path) + 1 + strlen(libdir_path) + 1 + (strlen(libdir_path) + 2) + 1;
 		char *newenv = malloc(len);
 		if (!newenv) {
-			pseudo_diag("fatal: can't allocate new %s variable.\n", PRELINK_PATH);
+			pseudo_error("can't allocate new %s variable.\n", PRELINK_PATH);
 		} else {
 		    snprintf(newenv, len, "%s:%s:%s64", ld_library_path, libdir_path, libdir_path);
 		    new_envp[j++] = newenv;
@@ -1247,18 +1247,18 @@ pseudo_setupenvp(char * const *envp) {
 	if (ld_preload) {
 		ld_preload = with_libpseudo(ld_preload, libdir_path);
 		if (!ld_preload) {
-			pseudo_diag("fatal: can't allocate new %s variable.\n", PRELINK_LIBRARIES);
+			pseudo_error("can't allocate new %s variable.\n", PRELINK_LIBRARIES);
 		} else
 			new_envp[j++] = ld_preload;
 	} else {
 		ld_preload = with_libpseudo("", libdir_path);
 		if (!ld_preload) {
-			pseudo_diag("fatal: can't allocate new %s variable.\n", PRELINK_LIBRARIES);
+			pseudo_error("can't allocate new %s variable.\n", PRELINK_LIBRARIES);
 		} else {
 			size_t len = strlen(PRELINK_LIBRARIES "=") + strlen(ld_preload) + 1;
 			char *newenv = malloc(len);
 			if (!newenv) {
-				pseudo_diag("fatal: can't allocate new %s variable.\n", PRELINK_LIBRARIES);
+				pseudo_error("can't allocate new %s variable.\n", PRELINK_LIBRARIES);
 			} else {
 				snprintf(newenv, len, PRELINK_LIBRARIES "=%s", ld_preload);
 				new_envp[j++] = newenv;
@@ -1287,7 +1287,7 @@ pseudo_setupenvp(char * const *envp) {
 			size_t len = strlen(pseudo_env[i].key) + 1 + strlen(pseudo_env[i].value) + 1;
 			char *newenv = malloc(len);
 			if (!newenv) {
-				pseudo_diag("fatal: can't allocate new variable.\n");
+				pseudo_error("can't allocate new variable.\n");
 			} else {
 				snprintf(newenv, len, "%s=%s", pseudo_env[i].key, pseudo_env[i].value);
 				new_envp[j++] = newenv;
@@ -1339,7 +1339,7 @@ pseudo_prefix_path(char *file) {
 	char * prefix = pseudo_get_prefix(NULL);
 
 	if (!prefix) {
-		pseudo_diag("You must set the PSEUDO_PREFIX environment variable to run pseudo.\n");
+		pseudo_error("You must set the PSEUDO_PREFIX environment variable to run pseudo.\n");
 		exit(1);
 	}
 
@@ -1356,7 +1356,7 @@ pseudo_bindir_path(char *file) {
 	char * bindir = pseudo_get_bindir();
 
 	if (!bindir) {
-		pseudo_diag("You must set the PSEUDO_BINDIR environment variable to run pseudo.\n");
+		pseudo_error("You must set the PSEUDO_BINDIR environment variable to run pseudo.\n");
 		exit(1);
 	}
 
@@ -1373,7 +1373,7 @@ pseudo_libdir_path(char *file) {
 	char * libdir = pseudo_get_libdir();
 
 	if (!libdir) {
-		pseudo_diag("You must set the PSEUDO_LIBDIR environment variable to run pseudo.\n");
+		pseudo_error("You must set the PSEUDO_LIBDIR environment variable to run pseudo.\n");
 		exit(1);
 	}
 
@@ -1390,7 +1390,7 @@ pseudo_localstatedir_path(char *file) {
 	char * localstatedir = pseudo_get_localstatedir();
 
 	if (!localstatedir) {
-		pseudo_diag("You must set the PSEUDO_LOCALSTATEDIR environment variable to run pseudo.\n");
+		pseudo_error("You must set the PSEUDO_LOCALSTATEDIR environment variable to run pseudo.\n");
 		exit(1);
 	}
 
@@ -1424,7 +1424,7 @@ pseudo_get_prefix(char *pathname) {
 		tmp_path = pseudo_fix_path(NULL, mypath, 0, 0, 0, AT_SYMLINK_NOFOLLOW);
 		/* point s to the end of the fixed path */
 		if ((int) strlen(tmp_path) >= pseudo_path_max()) {
-			pseudo_diag("Can't expand path '%s' -- expansion exceeds %d.\n",
+			pseudo_error("Can't expand path '%s' -- expansion exceeds %d.\n",
 				mypath, (int) pseudo_path_max());
 		} else {
 			s = mypath + snprintf(mypath, pseudo_path_max(), "%s", tmp_path);
@@ -1446,7 +1446,7 @@ pseudo_get_prefix(char *pathname) {
 			strcpy(mypath, "/");
 		}
 
-		pseudo_diag("Warning: PSEUDO_PREFIX unset, defaulting to %s.\n",
+		pseudo_warning("PSEUDO_PREFIX unset, defaulting to %s.\n",
 			mypath);
 		pseudo_set_value("PSEUDO_PREFIX", mypath);
 		s = pseudo_get_value("PSEUDO_PREFIX");
@@ -1702,7 +1702,7 @@ pseudo_logfile(char *filename, char *defname, int prefer_fd) {
 		}
 		pseudo_path = pseudo_localstatedir_path(defname);
 		if (!pseudo_path) {
-			pseudo_diag("can't get path for prefix/%s\n", PSEUDO_LOGFILE);
+			pseudo_error("can't get path for prefix/%s\n", PSEUDO_LOGFILE);
 			return -1;
 		}
 	} else {
@@ -1716,7 +1716,7 @@ pseudo_logfile(char *filename, char *defname, int prefer_fd) {
 					break;
 				case 'd':
 					if (pid) {
-						pseudo_diag("found second %%d in PSEUDO_DEBUG_FILE, ignoring.\n");
+						pseudo_info("found second %%d in PSEUDO_DEBUG_FILE, ignoring.\n");
 						return -1;
 					} else {
 						pid = s;
@@ -1724,7 +1724,7 @@ pseudo_logfile(char *filename, char *defname, int prefer_fd) {
 					break;
 				case 's':
 					if (prog) {
-						pseudo_diag("found second %%s in PSEUDO_DEBUG_FILE, ignoring.\n");
+						pseudo_info("found second %%s in PSEUDO_DEBUG_FILE, ignoring.\n");
 						return -1;
 					} else {
 						prog = s;
@@ -1732,10 +1732,10 @@ pseudo_logfile(char *filename, char *defname, int prefer_fd) {
 					break;
 				default:
 					if (isprint(s[1])) {
-						pseudo_diag("found unknown format character '%c' in PSEUDO_DEBUG_FILE, ignoring.\n",
+						pseudo_info("found unknown format character '%c' in PSEUDO_DEBUG_FILE, ignoring.\n",
 							s[1]);
 					} else {
-						pseudo_diag("found unknown format character '\\x%02x' in PSEUDO_DEBUG_FILE, ignoring.\n",
+						pseudo_info("found unknown format character '\\x%02x' in PSEUDO_DEBUG_FILE, ignoring.\n",
 							(unsigned char) s[1]);
 					}
 					return -1;
@@ -1750,7 +1750,7 @@ pseudo_logfile(char *filename, char *defname, int prefer_fd) {
 			len += strlen(program_invocation_short_name);
 		pseudo_path = malloc(len);
 		if (!pseudo_path) {
-			pseudo_diag("can't allocate space for debug file name.\n");
+			pseudo_error("can't allocate space for debug file name.\n");
 			return -1;
 		}
 		if (pid && prog) {
@@ -1770,7 +1770,7 @@ pseudo_logfile(char *filename, char *defname, int prefer_fd) {
 	}	
 	fd = open(pseudo_path, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0644);
 	if (fd == -1) {
-		pseudo_diag("help: can't open log file %s: %s\n", pseudo_path, strerror(errno));
+		pseudo_error("help: can't open log file %s: %s\n", pseudo_path, strerror(errno));
 	} else {
 		/* try to force fd to prefer_fd.  We do this because glibc's malloc
 		 * debug unconditionally writes to fd 2, and we don't want
@@ -1799,7 +1799,7 @@ pseudo_debug_logfile(char *defname, int prefer_fd) {
 
 	fd = pseudo_logfile(filename, defname, prefer_fd);
 	if (fd > -1) {
-		pseudo_diag("debug_logfile: fd %d\n", fd);
+		pseudo_info("debug_logfile: fd %d\n", fd);
 		pseudo_util_debug_fd = fd;
 		return 0;
 	}
@@ -1864,7 +1864,7 @@ pseudo_dump_data(char *name, const void *v, size_t len) {
 	const unsigned char *base = v;
 	const unsigned char *data = base;
 	int remaining = len;
-	pseudo_diag("%s at %p [%d byte%s]:\n",
+	pseudo_info("%s at %p [%d byte%s]:\n",
 		name ? name : "data", v, (int) len, len == 1 ? "" : "s");
 	while (remaining > 0) {
 		char *hexptr = hexbuf;
@@ -1882,7 +1882,7 @@ pseudo_dump_data(char *name, const void *v, size_t len) {
 		}
 		*hexptr = '\0';
 		*asciiptr = '\0';
-		pseudo_diag("0x%06x %-50.50s '%.16s'\n",
+		pseudo_info("0x%06x %-50.50s '%.16s'\n",
 			(int) (data - base),
 			hexbuf, asciibuf);
 		remaining = remaining - 16;

base-commit: f554e5d2b207eb96754d2c62784419a46cb364ba

#1 lore raw

PATCH 2/8 pseudo_db: Change pseudo_diag() calls to appropriate macros

From: Dmitry Sakhonchik <[email protected]>

Implements [YOCTO #12141]

---
 pseudo_db.c | 122 ++++++++++++++++++++++++++--------------------------
 1 file changed, 61 insertions(+), 61 deletions(-)
pseudo_db.c +61 -61
index 6a33f20..6945a83 100644
@@ -27,7 +27,7 @@
 #ifdef NPROFILE
 void xProfile(void * pArg, const char * pQuery, sqlite3_uint64 pTimeTaken)
 {
-       pseudo_diag("profile: %lld %s\n", pTimeTaken, pQuery);
+       pseudo_info("profile: %lld %s\n", pTimeTaken, pQuery);
 }
 #endif
 
@@ -647,7 +647,7 @@ cleanup_db(void) {
 	localtime_r(&stamp.tv_sec, &stamp_tm);
 	strftime(datebuf, 64, "%H:%M:%S", &stamp_tm);
 
-	pseudo_diag("db cleanup for server shutdown, %s.%03d\n",
+	pseudo_info("db cleanup for server shutdown, %s.%03d\n",
 		datebuf, (int) (stamp.tv_usec / 1000));
 #ifdef USE_MEMORY_DB
         if (real_file_db) {
@@ -657,7 +657,7 @@ cleanup_db(void) {
 	gettimeofday(&stamp, NULL);
 	localtime_r(&stamp.tv_sec, &stamp_tm);
 	strftime(datebuf, 64, "%H:%M:%S", &stamp_tm);
-	pseudo_diag("memory-to-file backup complete, %s.%03d.\n",
+	pseudo_info("memory-to-file backup complete, %s.%03d.\n",
 		datebuf, (int) (stamp.tv_usec / 1000));
 #endif
 	if (file_db)
@@ -667,7 +667,7 @@ cleanup_db(void) {
 	gettimeofday(&stamp, NULL);
 	localtime_r(&stamp.tv_sec, &stamp_tm);
 	strftime(datebuf, 64, "%H:%M:%S", &stamp_tm);
-	pseudo_diag("db cleanup finished, %s.%03d\n",
+	pseudo_info("db cleanup finished, %s.%03d\n",
 		datebuf, (int) (stamp.tv_usec / 1000));
 }
 
@@ -704,7 +704,7 @@ get_db(struct database_info *dbinfo) {
                 rc = sqlite3_open(dbfile, &db);
 	free(dbfile);
 	if (rc) {
-		pseudo_diag("Failed: %s\n", sqlite3_errmsg(db));
+		pseudo_error("Failed: %s\n", sqlite3_errmsg(db));
 		sqlite3_close(db);
 		*(dbinfo->db) = NULL;
 		return 1;
@@ -733,7 +733,7 @@ get_db(struct database_info *dbinfo) {
 		"ORDER BY name;";
 	rc = sqlite3_get_table(db, sql, &results, &rows, &columns, &errmsg);
 	if (rc) {
-		pseudo_diag("Failed: %s\n", errmsg);
+		pseudo_error("Failed: %s\n", errmsg);
 	} else {
 		rc = make_tables(db, dbinfo->tables, dbinfo->indexes, dbinfo->migrations, results, rows);
 		sqlite3_free_table(results);
@@ -760,7 +760,7 @@ get_dbs(void) {
 #endif
 	for (i = 0; db_infos[i].db; ++i) {
 		if (get_db(&db_infos[i])) {
-			pseudo_diag("Error getting '%s' database.\n",
+			pseudo_error("Error getting '%s' database.\n",
 				db_infos[i].pathname);
 			err = 1;
 		}
@@ -780,12 +780,12 @@ pdb_log_traits(pseudo_query_t *traits) {
 	int rc;
 
 	if (!log_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 1;
 	}
 	e = calloc(1, sizeof(*e));
 	if (!e) {
-		pseudo_diag("can't allocate space for log entry.");
+		pseudo_error("can't allocate space for log entry.");
 		return 1;
 	}
 	for (trait = traits; trait; trait = trait->next) {
@@ -854,7 +854,7 @@ pdb_log_traits(pseudo_query_t *traits) {
 		case PSQF_ID:
 		case PSQF_ORDER:
 		default:
-			pseudo_diag("Invalid trait %s for log creation.\n",
+			pseudo_error("Invalid trait %s for log creation.\n",
 				pseudo_query_field_name(trait->field));
 			free(e);
 			return 1;
@@ -878,7 +878,7 @@ pdb_log_entry(log_entry *e) {
 	int rc;
 
 	if (!log_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 1;
 	}
 
@@ -976,7 +976,7 @@ pdb_log_msg(pseudo_sev_t severity, pseudo_msg_t *msg, const char *program, const
 	}
 
 	if (!log_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 1;
 	}
 
@@ -1062,7 +1062,7 @@ frag(buffer *b, char *fmt, ...) {
 	int rc;
 
 	if (!b) {
-		pseudo_diag("frag called without buffer.\n");
+		pseudo_error("frag called without buffer.\n");
 		return -1;
 	}
 	curlen = b->tail - b->data;
@@ -1075,7 +1075,7 @@ frag(buffer *b, char *fmt, ...) {
 			newlen *= 2;
 		char *newbuf = malloc(newlen);
 		if (!newbuf) {
-			pseudo_diag("failed to allocate SQL buffer.\n");
+			pseudo_error("failed to allocate SQL buffer.\n");
 			return -1;
 		}
 		memcpy(newbuf, b->data, curlen + 1);
@@ -1088,7 +1088,7 @@ frag(buffer *b, char *fmt, ...) {
 		rc = vsnprintf(b->tail, b->buflen - curlen, fmt, ap);
 		va_end(ap);
 		if ((rc > 0) && ((size_t) rc >= (b->buflen - curlen))) {
-			pseudo_diag("tried to reallocate larger buffer, failed.  giving up.\n");
+			pseudo_error("tried to reallocate larger buffer, failed.  giving up.\n");
 			return -1;
 		}
 	}
@@ -1110,24 +1110,24 @@ pdb_query(char *stmt_type, pseudo_query_t *traits, unsigned long fields, int uni
 	static buffer *sql;
 
 	if (!log_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return NULL;
 	}
 
 	if (!stmt_type) {
-		pseudo_diag("can't prepare a statement without a type.\n");
+		pseudo_warning("can't prepare a statement without a type.\n");
 	}
 
 	if (!sql) {
 		sql = malloc(sizeof *sql);
 		if (!sql) {
-			pseudo_diag("can't allocate SQL buffer.\n");
+			pseudo_error("can't allocate SQL buffer.\n");
 			return NULL;
 		}
 		sql->buflen = 512;
 		sql->data = malloc(sql->buflen);
 		if (!sql->data) {
-			pseudo_diag("can't allocate SQL text buffer.\n");
+			pseudo_error("can't allocate SQL text buffer.\n");
 			free(sql);
 			sql = 0;
 			return NULL;
@@ -1193,7 +1193,7 @@ pdb_query(char *stmt_type, pseudo_query_t *traits, unsigned long fields, int uni
 			case PSQT_LIKE:
 			case PSQT_NOTLIKE:
 			case PSQT_SQLPAT:
-				pseudo_diag("Error:  Can't use a LIKE match on non-text fields.\n");
+				pseudo_error("Can't use a LIKE match on non-text fields.\n");
 				return 0;
 				break;
 			default:
@@ -1210,7 +1210,7 @@ pdb_query(char *stmt_type, pseudo_query_t *traits, unsigned long fields, int uni
 			case PSQT_LIKE:
 			case PSQT_NOTLIKE:
 			case PSQT_SQLPAT:
-				pseudo_diag("Error:  Can't use a LIKE match on non-text fields.\n");
+				pseudo_error("Error:  Can't use a LIKE match on non-text fields.\n");
 				return 0;
 				break;
 			default:
@@ -1235,7 +1235,7 @@ pdb_query(char *stmt_type, pseudo_query_t *traits, unsigned long fields, int uni
 				order_dir = "ASC";
 				break;
 			default:
-				pseudo_diag("Ordering must be < or >.\n");
+				pseudo_error("Ordering must be < or >.\n");
 				return 0;
 				break;
 			}
@@ -1245,7 +1245,7 @@ pdb_query(char *stmt_type, pseudo_query_t *traits, unsigned long fields, int uni
 			case PSQT_LIKE:
 			case PSQT_NOTLIKE:
 			case PSQT_SQLPAT:
-				pseudo_diag("Error:  Can't use a LIKE match on non-text fields.\n");
+				pseudo_error("Can't use a LIKE match on non-text fields.\n");
 				return 0;
 				break;
 			default:
@@ -1300,7 +1300,7 @@ pdb_query(char *stmt_type, pseudo_query_t *traits, unsigned long fields, int uni
 			sqlite3_bind_int64(stmt, field++, trait->data.ivalue);
 			break;
 		default:
-			pseudo_diag("Inexplicably invalid field type %d\n", trait->field);
+			pseudo_error("Inexplicably invalid field type %d\n", trait->field);
 			sqlite3_finalize(stmt);
 			return NULL;
 		}
@@ -1322,7 +1322,7 @@ pdb_delete(pseudo_query_t *traits, unsigned long fields) {
 			dberr(log_db, "deletion failed");
 			return -1;
 		} else {
-			pseudo_diag("Deleted records, vacuuming log database (may take a while).\n");
+			pseudo_info("Deleted records, vacuuming log database (may take a while).\n");
 			/* we can't do anything about it if this fails... */
 			sqlite3_exec(log_db, "VACUUM;", NULL, NULL, NULL);
 		}
@@ -1347,7 +1347,7 @@ pdb_history(pseudo_query_t *traits, unsigned long fields, int unique) {
 			h->fields = fields;
 			h->stmt = stmt;
 		} else {
-			pseudo_diag("failed to allocate memory for log_history\n");
+			pseudo_error("failed to allocate memory for log_history\n");
 			sqlite3_finalize(stmt);
 		}
 		return h;
@@ -1378,7 +1378,7 @@ pdb_history_entry(log_history h) {
 	}
 	l = calloc(1, sizeof(log_entry));
 	if (!l) {
-		pseudo_diag("couldn't allocate log entry.\n");
+		pseudo_error("couldn't allocate log entry.\n");
 		return 0;
 	}
 
@@ -1449,12 +1449,12 @@ pdb_history_entry(log_history h) {
 		case PSQF_ORDER:
 		case PSQF_FTYPE:
 		case PSQF_PERM:
-			pseudo_diag("field %s should not be in the fields list.\n",
+			pseudo_warning("field %s should not be in the fields list.\n",
 				pseudo_query_field_name(f));
 			return 0;
 			break;
 		default:
-			pseudo_diag("unknown field %d\n", f);
+			pseudo_warning("unknown field %d\n", f);
 			return 0;
 			break;
 		}
@@ -1498,7 +1498,7 @@ pdb_clear_unused_xattrs(void) {
 	int rc;
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return;
 	}
 	if (!delete) {
@@ -1528,7 +1528,7 @@ pdb_clear_xattrs(pseudo_msg_t *msg) {
 	if (!msg)
 		return;
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return;
 	}
 	if (!delete) {
@@ -1565,7 +1565,7 @@ pdb_copy_xattrs(pseudo_msg_t *oldmsg, pseudo_msg_t *msg) {
 	if (!oldmsg || !msg)
 		return;
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return;
 	}
 	if (!copy) {
@@ -1596,7 +1596,7 @@ pdb_check_xattrs(pseudo_msg_t *msg) {
 	if (!msg)
 		return;
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return;
 	}
 	if (!scan) {
@@ -1643,7 +1643,7 @@ pdb_link_file(pseudo_msg_t *msg) {
 		    " VALUES (?, ?, ?, ?, ?, ?, ?, 0);";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!insert) {
@@ -1689,7 +1689,7 @@ pdb_unlink_file_dev(pseudo_msg_t *msg) {
 	char *sql = "DELETE FROM files WHERE dev = ? AND ino = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!sql_delete) {
@@ -1724,7 +1724,7 @@ pdb_update_file_path(pseudo_msg_t *msg) {
 		"WHERE path = 'NAMELESS FILE' and dev = ? AND ino = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!update) {
@@ -1759,7 +1759,7 @@ pdb_may_unlink_file(pseudo_msg_t *msg, int deleting) {
 	char *sql_mark_file = "UPDATE files SET deleting = ? WHERE path = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!mark_file) {
@@ -1804,7 +1804,7 @@ pdb_cancel_unlink_file(pseudo_msg_t *msg) {
 	char *sql_mark_file = "UPDATE files SET deleting = 0 WHERE path = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!mark_file) {
@@ -1846,7 +1846,7 @@ pdb_did_unlink_files(int deleting) {
 	char *sql_delete_exact = "DELETE FROM files WHERE deleting = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!delete_exact) {
@@ -1857,7 +1857,7 @@ pdb_did_unlink_files(int deleting) {
 		}
 	}
 	if (deleting == 0) {
-		pseudo_diag("did_unlink_files: deleting must be non-zero.\n");
+		pseudo_error("did_unlink_files: deleting must be non-zero.\n");
 		return 0;
 	}
 	sqlite3_bind_int(delete_exact, 1, deleting);
@@ -1882,7 +1882,7 @@ pdb_did_unlink_file(char *path, pseudo_msg_t *msg, int deleting) {
 	char *sql_delete_exact = "DELETE FROM files WHERE path = ? AND deleting = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!delete_exact) {
@@ -1925,7 +1925,7 @@ pdb_unlink_file(pseudo_msg_t *msg) {
 	char *sql_delete_exact = "DELETE FROM files WHERE path = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!delete_exact) {
@@ -1973,7 +1973,7 @@ pdb_unlink_contents(pseudo_msg_t *msg) {
 				"(path > (? || '/') AND path < (? || '0'));";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!delete_sub) {
@@ -2025,7 +2025,7 @@ pdb_rename_file(const char *oldpath, pseudo_msg_t *msg) {
 			       "WHERE (path > (? || '/') AND path < (? || '0'));";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!update_exact) {
@@ -2098,7 +2098,7 @@ pdb_renumber_all(dev_t from, dev_t to) {
 		    " WHERE dev = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!files_update) {
@@ -2166,7 +2166,7 @@ pdb_update_inode(pseudo_msg_t *msg) {
 	if (!oldmsg) {
 		oldmsg = malloc(sizeof(*msg) + pseudo_path_max());
 		if (!oldmsg) {
-			pseudo_diag("%s: out of memory\n", __func__);
+			pseudo_error("%s: out of memory\n", __func__);
 			return 1;
 		}
 	}
@@ -2175,7 +2175,7 @@ pdb_update_inode(pseudo_msg_t *msg) {
 		    " SET dev = ?, ino = ? "
 		    " WHERE path = ?;";
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!update) {
@@ -2189,7 +2189,7 @@ pdb_update_inode(pseudo_msg_t *msg) {
 		return 1;
 	}
 	if (!msg->pathlen) {
-		pseudo_diag("Can't update the inode of a file without its path.\n");
+		pseudo_error("Can't update the inode of a file without its path.\n");
 		return 1;
 	}
 	memcpy(oldmsg, msg, sizeof(*msg) + msg->pathlen);
@@ -2240,7 +2240,7 @@ pdb_update_file(pseudo_msg_t *msg) {
 		    " WHERE dev = ? AND ino = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!update) {
@@ -2281,7 +2281,7 @@ pdb_find_file_exact(pseudo_msg_t *msg) {
 	char *sql = "SELECT * FROM files WHERE path = ? AND dev = ? AND ino = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!select) {
@@ -2332,7 +2332,7 @@ pdb_find_file_path(pseudo_msg_t *msg) {
 	char *sql = "SELECT * FROM files WHERE path = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 1;
 	}
 	if (!select) {
@@ -2389,7 +2389,7 @@ pdb_get_file_path(pseudo_msg_t *msg) {
 	char *response;
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!select) {
@@ -2438,7 +2438,7 @@ pdb_find_file_dev(pseudo_msg_t *msg, char **path) {
 	char *sql = "SELECT * FROM files WHERE dev = ? AND ino = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!select) {
@@ -2492,7 +2492,7 @@ pdb_get_xattr(pseudo_msg_t *msg, char **value, size_t *len) {
 	char *sql = "SELECT value FROM xattrs WHERE dev  = ? AND ino = ? AND name = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!select) {
@@ -2523,7 +2523,7 @@ pdb_get_xattr(pseudo_msg_t *msg, char **value, size_t *len) {
 			 */
 			*value = malloc(length);
 			if (!*value) {
-				pseudo_diag("%s: out of memory\n", __func__);
+				pseudo_error("%s: out of memory\n", __func__);
 				sqlite3_reset(select);
 				sqlite3_clear_bindings(select);
 				return 1;
@@ -2561,7 +2561,7 @@ pdb_list_xattr(pseudo_msg_t *msg, char **value, size_t *len) {
 	char *sql = "SELECT name FROM xattrs WHERE dev = ? AND ino = ? ORDER BY name;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!select) {
@@ -2615,7 +2615,7 @@ pdb_remove_xattr(pseudo_msg_t *msg, char *value, size_t len) {
 	char *sql = "DELETE FROM xattrs WHERE dev = ? AND ino = ? AND name = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!delete) {
@@ -2656,7 +2656,7 @@ pdb_set_xattr(pseudo_msg_t *msg, char *value, size_t len, int flags) {
 	size_t vlen;
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!select) {
@@ -2769,7 +2769,7 @@ pdb_find_file_ino(pseudo_msg_t *msg) {
 	char *sql = "SELECT * FROM files WHERE ino = ?;";
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 	if (!select) {
@@ -2813,7 +2813,7 @@ pdb_files(void) {
 	pdb_file_list l;
 
 	if (!file_db && get_dbs()) {
-		pseudo_diag("%s: database error.\n", __func__);
+		pseudo_error("%s: database error.\n", __func__);
 		return 0;
 	}
 
@@ -2852,7 +2852,7 @@ pdb_file(pdb_file_list l) {
 	s = sqlite3_column_text(l->stmt, column++);
 	m = pseudo_msg_new(0, (const char *) s);
 	if (!m) {
-		pseudo_diag("couldn't allocate file message.\n");
+		pseudo_error("couldn't allocate file message.\n");
 		return NULL;
 	}
 	pseudo_debug(PDBGF_DB, "pdb_file: '%s'\n", s ? (const char *) s : "<nil>");
#2 lore raw

PATCH 3/8 pseudo_client: Change pseudo_diag() calls to appropriate macros

In reply to [email protected]

From: Dmitry Sakhonchik <[email protected]>

Implements [YOCTO #12141]

---
 pseudo_client.c | 96 ++++++++++++++++++++++++-------------------------
 1 file changed, 47 insertions(+), 49 deletions(-)
pseudo_client.c +47 -49
index 7041366..69e5cbc 100644
@@ -166,7 +166,7 @@ build_passwd_paths(void)
 		/* allocation and/or return */
 		if (passwd_paths) {
 			if (np != npasswd_paths) {
-				pseudo_diag("internal error: path allocation was inconsistent.\n");
+				pseudo_error("internal error: path allocation was inconsistent.\n");
 			} else {
 				/* yes, we allocated one extra for a trailing
 				 * null pointer.
@@ -178,14 +178,14 @@ build_passwd_paths(void)
 			passwd_paths = malloc((np + 1) * sizeof(*passwd_paths));
 			npasswd_paths = np;
 			if (!passwd_paths) {
-				pseudo_diag("couldn't allocate storage for password paths.\n");
+				pseudo_error("couldn't allocate storage for password paths.\n");
 				exit(1);
 			}
 			np = 0;
 		}
 	} while (++pass < 2);
 	/* in theory the second pass already returned, but. */
-	pseudo_diag("should totally not have gotten here.\n");
+	pseudo_error("should totally not have gotten here.\n");
 
 	return;
 }
@@ -567,11 +567,11 @@ pseudo_init_client(void) {
 				}
 				pseudo_prefix_dir_fd = pseudo_fd(pseudo_prefix_dir_fd, MOVE_FD);
 			} else {
-				pseudo_diag("No prefix available to to find server.\n");
+				pseudo_error("No prefix available to to find server.\n");
 				exit(1);
 			}
 			if (pseudo_prefix_dir_fd == -1) {
-				pseudo_diag("Can't open prefix path '%s' for server: %s\n",
+				pseudo_error("Can't open prefix path '%s' for server: %s\n",
 					pseudo_path,
 					strerror(errno));
 				exit(1);
@@ -590,11 +590,11 @@ pseudo_init_client(void) {
 				}
 				pseudo_localstate_dir_fd = pseudo_fd(pseudo_localstate_dir_fd, MOVE_FD);
 			} else {
-				pseudo_diag("No local state directory available for server/file interactions.\n");
+				pseudo_error("No local state directory available for server/file interactions.\n");
 				exit(1);
 			}
 			if (pseudo_localstate_dir_fd == -1) {
-				pseudo_diag("Can't open local state path '%s': %s\n",
+				pseudo_error("Can't open local state path '%s': %s\n",
 					pseudo_path,
 					strerror(errno));
 				exit(1);
@@ -633,7 +633,7 @@ pseudo_init_client(void) {
 			if (pseudo_chroot) {
 				pseudo_chroot_len = strlen(pseudo_chroot);
 			} else {
-				pseudo_diag("Can't store chroot path '%s'\n", env);
+				pseudo_error("Can't store chroot path '%s'\n", env);
 			}
 		}
 		free(env);
@@ -662,7 +662,7 @@ pseudo_init_client(void) {
 static void
 pseudo_file_close(int *fd, FILE **fp) {
 	if (!fp || !fd) {
-		pseudo_diag("pseudo_file_close: needs valid pointers.\n");
+		pseudo_error("pseudo_file_close: needs valid pointers.\n");
 		return;
 	}
 	pseudo_antimagic();
@@ -698,7 +698,7 @@ pseudo_file_close(int *fd, FILE **fp) {
 static FILE *
 pseudo_file_open(char *name, int *fd, FILE **fp) {
 	if (!fp || !fd || !name) {
-		pseudo_diag("pseudo_file_open: needs valid pointers.\n");
+		pseudo_error("pseudo_file_open: needs valid pointers.\n");
 		return NULL;
 	}
 	pseudo_file_close(fd, fp);
@@ -734,7 +734,7 @@ pseudo_pwd_lck_open(void) {
 	if (!pseudo_pwd_lck_name) {
 		pseudo_pwd_lck_name = malloc(pseudo_path_max());
 		if (!pseudo_pwd_lck_name) {
-			pseudo_diag("couldn't allocate space for passwd lockfile path.\n");
+			pseudo_error("couldn't allocate space for passwd lockfile path.\n");
 			return -1;
 		}
 	}
@@ -815,7 +815,7 @@ pseudo_client_chroot(const char *path) {
 	pseudo_chroot_len = strlen(path);
 	pseudo_chroot = malloc(pseudo_chroot_len + 1);
 	if (!pseudo_chroot) {
-		pseudo_diag("Couldn't allocate chroot directory buffer.\n");
+		pseudo_error("Couldn't allocate chroot directory buffer.\n");
 		pseudo_chroot_len = 0;
 		errno = ENOMEM;
 		return -1;
@@ -834,7 +834,7 @@ pseudo_root_path(const char *func, int line, int dirfd, const char *path, int le
 	rc = base_path(dirfd, path, leave_last);
 	pseudo_magic();
 	if (!rc) {
-		pseudo_diag("couldn't allocate absolute path for '%s'.\n",
+		pseudo_error("couldn't allocate absolute path for '%s'.\n",
 			path ? path : "null");
 	}
 	pseudo_debug(PDBGF_CHROOT, "root_path [%s, %d]: '%s' from '%s'\n",
@@ -849,7 +849,7 @@ pseudo_client_getcwd(void) {
 	char *cwd;
 	cwd = malloc(pseudo_path_max());
 	if (!cwd) {
-		pseudo_diag("Can't allocate CWD buffer!\n");
+		pseudo_error("Can't allocate CWD buffer!\n");
 		return -1;
 	}
 	pseudo_debug(PDBGF_CLIENT | PDBGF_VERBOSE, "getcwd: trying to find cwd.\n");
@@ -874,7 +874,7 @@ pseudo_client_getcwd(void) {
 		}
 		return 0;
 	} else {
-		pseudo_diag("Can't get CWD: %s\n", strerror(errno));
+		pseudo_error("Can't get CWD: %s\n", strerror(errno));
 		return -1;
 	}
 }
@@ -901,7 +901,7 @@ pseudo_client_path_set(int fd, const char *path, char ***patharray, int *len) {
 			*len, fd + 1);
 		(*patharray) = realloc((*patharray), (fd + 1) * sizeof(char *));
 		if (!*patharray) {
-			pseudo_diag("couldn't realloc fd path array to %ld entries\n", (fd + 1) * sizeof(char *));
+			pseudo_error("couldn't realloc fd path array to %ld entries\n", (fd + 1) * sizeof(char *));
 			exit(1);
 		}
 		for (i = *len; i < fd + 1; ++i)
@@ -1002,7 +1002,7 @@ client_spawn_server(void) {
 
 	if ((server_pid = pseudo_real_fork()) != 0) {
 		if (server_pid == -1) {
-			pseudo_diag("couldn't fork server: %s\n", strerror(errno));
+			pseudo_error("couldn't fork server: %s\n", strerror(errno));
 			return 1;
 		}
 		pseudo_evlog(PDBGF_CLIENT, "spawned new server, pid %d\n", server_pid);
@@ -1109,7 +1109,7 @@ client_spawn_server(void) {
 		pseudo_setupenv();
 		pseudo_dropenv();
 		pseudo_real_execv(argv[0], argv);
-		pseudo_diag("critical failure: exec of pseudo daemon failed: %s\n", strerror(errno));
+		pseudo_error("critical failure: exec of pseudo daemon failed: %s\n", strerror(errno));
 		exit(1);
 	}
 }
@@ -1187,7 +1187,7 @@ pseudo_fd(int fd, int how) {
 
 	/* Set close on exec, even if we didn't move it. */
 	if ((newfd >= 0) && (fcntl(newfd, F_SETFD, FD_CLOEXEC) < 0))
-		pseudo_diag("Can't set close on exec flag: %s\n",
+		pseudo_error("Can't set close on exec flag: %s\n",
 			strerror(errno));
 
 	return(newfd);
@@ -1208,7 +1208,7 @@ client_connect(void) {
 	pseudo_evlog(PDBGF_CLIENT, "creating socket %s.\n", sun.sun_path);
 	if (connect_fd == -1) {
 		char *e = strerror(errno);
-		pseudo_diag("Can't create socket: %s (%s)\n", sun.sun_path, e);
+		pseudo_error("Can't create socket: %s (%s)\n", sun.sun_path, e);
 		pseudo_evlog(PDBGF_CLIENT, "failed to create socket: %s\n", e);
 		return 1;
 	}
@@ -1216,14 +1216,14 @@ client_connect(void) {
 	pseudo_debug(PDBGF_CLIENT, "connecting socket...\n");
 	cwd_fd = open(".", O_RDONLY);
 	if (cwd_fd == -1) {
-		pseudo_diag("Couldn't stash directory before opening socket: %s",
+		pseudo_error("Couldn't stash directory before opening socket: %s",
 			strerror(errno));
 		close(connect_fd);
 		connect_fd = -1;
 		return 1;
 	}
 	if (fchdir(pseudo_localstate_dir_fd) == -1) {
-		pseudo_diag("Couldn't chdir to server directory [%d]: %s\n",
+		pseudo_error("Couldn't chdir to server directory [%d]: %s\n",
 			pseudo_localstate_dir_fd, strerror(errno));
 		close(connect_fd);
 		close(cwd_fd);
@@ -1236,7 +1236,7 @@ client_connect(void) {
 		pseudo_evlog(PDBGF_CLIENT, "connect failed: %s\n", e);
 		close(connect_fd);
 		if (fchdir(cwd_fd) == -1) {
-			pseudo_diag("return to previous directory failed: %s\n",
+			pseudo_error("return to previous directory failed: %s\n",
 				strerror(errno));
 		}
 		close(cwd_fd);
@@ -1244,7 +1244,7 @@ client_connect(void) {
 		return 1;
 	}
 	if (fchdir(cwd_fd) == -1) {
-		pseudo_diag("return to previous directory failed: %s\n",
+		pseudo_error("return to previous directory failed: %s\n",
 			strerror(errno));
 	}
 	close(cwd_fd);
@@ -1402,11 +1402,9 @@ pseudo_client_request(pseudo_msg_t *msg, size_t len, const char *path) {
 			}
 		}
 	}
-	pseudo_diag("pseudo: server connection persistently failed, aborting.\n");
+	pseudo_error("pseudo: server connection persistently failed, aborting.\n");
 	pseudo_evlog_dump();
-	pseudo_diag("event log dumped, aborting.\n");
-	abort();
-	pseudo_diag("aborted.\n");
+	pseudo_critical("event log dumped, aborting.\n");
 	return 0;
 }
 
@@ -1430,11 +1428,11 @@ pseudo_client_shutdown(int wait_on_socket) {
 			pseudo_prefix_dir_fd = pseudo_fd(pseudo_prefix_dir_fd, COPY_FD);
 			free(pseudo_path);
 		} else {
-			pseudo_diag("No prefix available to to find server.\n");
+			pseudo_error("No prefix available to to find server.\n");
 			exit(1);
 		}
 		if (pseudo_prefix_dir_fd == -1) {
-			pseudo_diag("Can't open prefix path (%s) for server. (%s)\n",
+			pseudo_error("Can't open prefix path (%s) for server. (%s)\n",
 				pseudo_prefix_path(NULL),
 				strerror(errno));
 			exit(1);
@@ -1454,11 +1452,11 @@ pseudo_client_shutdown(int wait_on_socket) {
 			pseudo_localstate_dir_fd = pseudo_fd(pseudo_localstate_dir_fd, COPY_FD);
 			free(pseudo_path);
 		} else {
-			pseudo_diag("No prefix available to to find server.\n");
+			pseudo_error("No prefix available to to find server.\n");
 			exit(1);
 		}
 		if (pseudo_localstate_dir_fd == -1) {
-			pseudo_diag("Can't open local state path (%s) for server. (%s)\n",
+			pseudo_error("Can't open local state path (%s) for server. (%s)\n",
 				pseudo_localstatedir_path(NULL),
 				strerror(errno));
 			exit(1);
@@ -1479,13 +1477,13 @@ pseudo_client_shutdown(int wait_on_socket) {
 	}
 	ack = pseudo_msg_receive(connect_fd);
 	if (!ack) {
-		pseudo_diag("server did not respond to shutdown query.\n");
+		pseudo_error("server did not respond to shutdown query.\n");
 		return 1;
 	}
 	if (ack->type != PSEUDO_MSG_ACK) {
-		pseudo_diag("Server refused shutdown.  Remaining client fds: %d\n", ack->fd);
-		pseudo_diag("Client pids: %s\n", ack->path);
-		pseudo_diag("Server will shut down after all clients exit.\n");
+		pseudo_info("Server refused shutdown.  Remaining client fds: %d\n", ack->fd);
+		pseudo_info("Client pids: %s\n", ack->path);
+		pseudo_info("Server will shut down after all clients exit.\n");
 	}
 	if (wait_on_socket) {
 		/* try to receive a message the server won't send;
@@ -1520,14 +1518,14 @@ base_path(int dirfd, const char *path, int leave_last) {
 			if (basepath) {
 				baselen = strlen(basepath);
 			} else {
-				pseudo_diag("got *at() syscall for unknown directory, fd %d\n", dirfd);
+				pseudo_error("got *at() syscall for unknown directory, fd %d\n", dirfd);
 			}
 		} else {
 			basepath = pseudo_cwd;
 			baselen = pseudo_cwd_len;
 		}
 		if (!basepath) {
-			pseudo_diag("unknown base path for fd %d, path %s\n", dirfd, path);
+			pseudo_error("unknown base path for fd %d, path %s\n", dirfd, path);
 			return 0;
 		}
 		/* if there's a chroot path, and it's the start of basepath,
@@ -1756,7 +1754,7 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
 	if (op == OP_RENAME) {
 		va_list ap;
 		if (!path) {
-			pseudo_diag("rename (%s) without new path.\n",
+			pseudo_warning("rename (%s) without new path.\n",
 				path ? path : "<nil>");
 			pseudo_magic();
 			return 0;
@@ -1766,7 +1764,7 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
 		va_end(ap);
 		/* last argument is the previous path of the file */
 		if (!path_extra_1) {
-			pseudo_diag("rename (%s) without old path.\n",
+			pseudo_warning("rename (%s) without old path.\n",
 				path ? path : "<nil>");
 			pseudo_magic();
 			return 0;
@@ -1835,7 +1833,7 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
 			alloced_path = malloc(full_len);
 			alloced_len = full_len;
 			if (!alloced_path) {
-				pseudo_diag("Can't allocate space for paths for a rename operation.  Sorry.\n");
+				pseudo_error("Can't allocate space for paths for a rename operation.  Sorry.\n");
 				alloced_len = 0;
 				pseudo_magic();
 				return 0;
@@ -1859,7 +1857,7 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
 				alloced_path = malloc(pathlen);
 				alloced_len = pathlen;
 				if (!alloced_path) {
-					pseudo_diag("Can't allocate space for paths for a rename operation.  Sorry.\n");
+					pseudo_error("Can't allocate space for paths for a rename operation.  Sorry.\n");
 					alloced_len = 0;
 					pseudo_magic();
 					return 0;
@@ -1965,7 +1963,7 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
 			if (fd == connect_fd) {
 				connect_fd = pseudo_fd(connect_fd, COPY_FD);
 				if (connect_fd == -1) {
-					pseudo_diag("tried to close connection, couldn't dup: %s\n", strerror(errno));
+					pseudo_error("tried to close connection, couldn't dup: %s\n", strerror(errno));
 				}
 			} else if (fd == pseudo_util_debug_fd) {
 				pseudo_util_debug_fd = pseudo_fd(fd, COPY_FD);
@@ -2037,7 +2035,7 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
 		do_request = 1;
 		break;
 	default:
-		pseudo_diag("error: unknown or unimplemented operator %d (%s)", op, pseudo_op_name(op));
+		pseudo_error("unknown or unimplemented operator %d (%s)", op, pseudo_op_name(op));
 		break;
 	}
 	/* result can only be set when PSEUDO_XATTRDB resulted in a
@@ -2069,7 +2067,7 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
 			pseudo_debug(PDBGF_OP, "(%d) %s", getpid(), pseudo_res_name(result->result));
 			if (result->result == RESULT_ABORT) {
 				char *local_state_dir = pseudo_get_value("PSEUDO_LOCALSTATEDIR");
-				pseudo_diag("abort()ing pseudo client by server request. See https://wiki.yoctoproject.org/wiki/Pseudo_Abort for more details on this.\n"
+				pseudo_info("abort()ing pseudo client by server request. See https://wiki.yoctoproject.org/wiki/Pseudo_Abort for more details on this.\n"
 					"Check logfile: %s/%s\n", local_state_dir, PSEUDO_LOGFILE);
 				abort();
 			}
@@ -2149,13 +2147,13 @@ populate_path_segs(void) {
 	}
 	path_segs = malloc((c+2) * sizeof(*path_segs));
 	if (!path_segs) {
-		pseudo_diag("warning: failed to allocate space for %d path segments.\n",
+		pseudo_warning("failed to allocate space for %d path segments.\n",
 			c);
 		return;
 	}
 	path_lens = malloc((c + 2) * sizeof(*path_lens));
 	if (!path_lens) {
-		pseudo_diag("warning: failed to allocate space for %d path lengths.\n",
+		pseudo_warning("failed to allocate space for %d path lengths.\n",
 			c);
 		free(path_segs);
 		path_segs = 0;
@@ -2163,7 +2161,7 @@ populate_path_segs(void) {
 	}
 	previous_path_segs = strdup(previous_path);
 	if (!previous_path_segs) {
-		pseudo_diag("warning: failed to allocate space for path copy.\n");
+		pseudo_warning("failed to allocate space for path copy.\n");
 		free(path_segs);
 		path_segs = NULL;
 		free(path_lens);
@@ -2242,7 +2240,7 @@ pseudo_exec_path(const char *filename, int search_path) {
 				candidate = pseudo_fix_path(dir, filename, 0, len, NULL, 0);
 				pseudo_debug(PDBGF_CLIENT, "exec_path: got %s for non-absolute path\n", candidate);
 			} else {
-				pseudo_diag("couldn't allocate intermediate path.\n");
+				pseudo_error("couldn't allocate intermediate path.\n");
 				candidate = NULL;
 			}
 		}
#3 lore raw

PATCH 4/8 pseudo_server: Change pseudo_diag() calls to appropriate macros

In reply to [email protected]

From: Dmitry Sakhonchik <[email protected]>

Implements [YOCTO #12141]

---
 pseudo_server.c | 92 ++++++++++++++++++++++++-------------------------
 1 file changed, 46 insertions(+), 46 deletions(-)
pseudo_server.c +46 -46
index edfbce1..c1a97c8 100644
@@ -68,7 +68,7 @@ void pseudo_antimagic(void) { }
 
 void
 quit_now(int signal) {
-	pseudo_diag("Received signal %d, quitting.\n", signal);
+	pseudo_info("Received signal %d, quitting.\n", signal);
 	die_forcefully = 1;
 }
 
@@ -116,12 +116,12 @@ pseudo_server_write_pid(pid_t pid) {
 
 	pseudo_path = pseudo_localstatedir_path(PSEUDO_PIDFILE);
 	if (!pseudo_path) {
-		pseudo_diag("Couldn't get path for prefix/%s\n", PSEUDO_PIDFILE);
+		pseudo_error("Couldn't get path for prefix/%s\n", PSEUDO_PIDFILE);
 		return 1;
 	}
 	fp = fopen(pseudo_path, "w");
 	if (!fp) {
-		pseudo_diag("Couldn't open %s: %s\n",
+		pseudo_error("Couldn't open %s: %s\n",
 			pseudo_path, strerror(errno));
 		return 1;
 	}
@@ -171,7 +171,7 @@ pseudo_server_start(int daemonize) {
 		pseudo_debug_logfile(PSEUDO_LOGFILE, 2);
 		child = fork();
 		if (child == -1) {
-			pseudo_diag("Couldn't fork child process: %s\n",
+			pseudo_error("Couldn't fork child process: %s\n",
 				strerror(errno));
 			exit(PSEUDO_EXIT_FORK_FAILED);
 		}
@@ -204,18 +204,18 @@ pseudo_server_start(int daemonize) {
 				exit(0);
 			}
 			if (got_sigalrm) {
-				pseudo_diag("Child process timeout after %d seconds.\n",
+				pseudo_error("Child process timeout after %d seconds.\n",
 					PSEUDO_CHILD_PROCESS_TIMEOUT);
 				exit(PSEUDO_EXIT_TIMEOUT);
 			}
 			if (rc == -1) {
-				pseudo_diag("Failure in waitpid(): %s\n",
+				pseudo_error("Failure in waitpid(): %s\n",
 					strerror(save_errno));
 				exit(PSEUDO_EXIT_WAITPID);
 			}
 			if (WIFSIGNALED(status)) {
 				status = WTERMSIG(status);
-				pseudo_diag("Child process exited from signal %d.\n",
+				pseudo_error("Child process exited from signal %d.\n",
 					status);
 				kill(getpid(), status);
 				/* can't use +128 because that's not valid */
@@ -223,15 +223,15 @@ pseudo_server_start(int daemonize) {
 			}
 			if (WIFEXITED(status)) {
 				status = WEXITSTATUS(status);
-				pseudo_diag("Child process exit status %d: %s\n",
+				pseudo_error("Child process exit status %d: %s\n",
 					status,
 					pseudo_exit_status_name(status));
 				if (status == 0) {
-					pseudo_diag("Hang on, server should not have exited 0 without sending us sigusr1?\n");
+					pseudo_error("Hang on, server should not have exited 0 without sending us sigusr1?\n");
 				}
 				exit(status);
 			}
-			pseudo_diag("Unknown exit status %d.\n", status);
+			pseudo_error("Unknown exit status %d.\n", status);
 			exit(PSEUDO_EXIT_GENERAL);
 		} else {
 			/* detach from parent session */
@@ -245,24 +245,24 @@ pseudo_server_start(int daemonize) {
 		}
 	}
 
-	pseudo_diag("pid %d [parent %d], doing new pid setup and server start\n", getpid(), getppid());
+	pseudo_info("pid %d [parent %d], doing new pid setup and server start\n", getpid(), getppid());
 	pseudo_new_pid();
 
 	pseudo_debug(PDBGF_SERVER, "opening lock.\n");
 	lockpath = pseudo_localstatedir_path(NULL);
 	if (!lockpath) {
-		pseudo_diag("Couldn't allocate a file path.\n");
+		pseudo_error("Couldn't allocate a file path.\n");
 		exit(PSEUDO_EXIT_LOCK_PATH);
 	}
 	mkdir_p(lockpath);
 	lockname = pseudo_localstatedir_path(PSEUDO_LOCKFILE);
 	if (!lockname) {
-		pseudo_diag("Couldn't allocate a file path.\n");
+		pseudo_error("Couldn't allocate a file path.\n");
 		exit(PSEUDO_EXIT_LOCK_PATH);
 	}
 	lockfd = open(lockname, O_RDWR | O_CREAT, 0644);
 	if (lockfd < 0) {
-		pseudo_diag("Can't open or create lockfile %s: %s\n",
+		pseudo_error("Can't open or create lockfile %s: %s\n",
 			lockname, strerror(errno));
 		exit(PSEUDO_EXIT_LOCK_FAILED);
 	}
@@ -275,7 +275,7 @@ pseudo_server_start(int daemonize) {
 	if (lockfd <= 2) {
 		newfd = fcntl(lockfd, F_DUPFD, 3);
 		if (newfd < 0) {
-			pseudo_diag("Can't move lockfile to safe descriptor, leaving it on %d: %s\n",
+			pseudo_warning("Can't move lockfile to safe descriptor, leaving it on %d: %s\n",
 				lockfd, strerror(errno));
 		} else {
 			close(lockfd);
@@ -297,11 +297,11 @@ pseudo_server_start(int daemonize) {
 		if (save_errno == EACCES || save_errno == EAGAIN) {
 			rc = fcntl(lockfd, F_GETLK, &lock_data);
 			if (rc == 0 && lock_data.l_type != F_UNLCK) {
-				pseudo_diag("lock already held by existing pid %d.\n",
+				pseudo_warning("lock already held by existing pid %d.\n",
 					lock_data.l_pid);
 			}
 		}
-		pseudo_diag("Couldn't obtain lock: %s.\n", strerror(save_errno));
+		pseudo_error("Couldn't obtain lock: %s.\n", strerror(save_errno));
 		exit(PSEUDO_EXIT_LOCK_HELD);
 
 	} else {
@@ -314,14 +314,14 @@ pseudo_server_start(int daemonize) {
 
 	listen_fd = socket(PF_UNIX, SOCK_STREAM, 0);
 	if (listen_fd < 0) {
-		pseudo_diag("couldn't create listening socket: %s\n", strerror(errno));
+		pseudo_error("couldn't create listening socket: %s\n", strerror(errno));
 		exit(PSEUDO_EXIT_SOCKET_CREATE);
 	}
 
 	if (listen_fd <= 2) {
 		newfd = fcntl(listen_fd, F_DUPFD, 3);
 		if (newfd < 0) {
-			pseudo_diag("couldn't dup listening socket: %s\n", strerror(errno));
+			pseudo_error("couldn't dup listening socket: %s\n", strerror(errno));
 			close(listen_fd);
 			exit(PSEUDO_EXIT_SOCKET_FD);
 		} else {
@@ -333,7 +333,7 @@ pseudo_server_start(int daemonize) {
 	/* cd to the data directory */
 	pseudo_path = pseudo_localstatedir_path(NULL);
 	if (!pseudo_path || chdir(pseudo_path) == -1) {
-		pseudo_diag("can't get to '%s': %s\n",
+		pseudo_error("can't get to '%s': %s\n",
 			pseudo_path, strerror(errno));
 		exit(PSEUDO_EXIT_SOCKET_PATH);
 	}
@@ -341,21 +341,21 @@ pseudo_server_start(int daemonize) {
 	/* remove existing socket -- if it exists */
 	rc = unlink(sun.sun_path);
 	if (rc == -1 && errno != ENOENT) {
-		pseudo_diag("Can't unlink existing socket: %s.\n",
+		pseudo_error("Can't unlink existing socket: %s.\n",
 			strerror(errno));
 		exit(PSEUDO_EXIT_SOCKET_UNLINK);
 	}
 	if (bind(listen_fd, (struct sockaddr *) &sun, sizeof(sun)) == -1) {
-		pseudo_diag("couldn't bind listening socket: %s\n", strerror(errno));
+		pseudo_error("couldn't bind listening socket: %s\n", strerror(errno));
 		exit(PSEUDO_EXIT_SOCKET_BIND);
 	}
 	if (listen(listen_fd, 5) == -1) {
-		pseudo_diag("couldn't listen on socket: %s\n", strerror(errno));
+		pseudo_error("couldn't listen on socket: %s\n", strerror(errno));
 		exit(PSEUDO_EXIT_SOCKET_LISTEN);
 	}
 	rc = pseudo_server_write_pid(getpid());
 	if (rc != 0) {
-		pseudo_diag("warning: couldn't write pid file.\n");
+		pseudo_warning("couldn't write pid file.\n");
 	}
 	signal(SIGHUP, quit_now);
 	signal(SIGINT, quit_now);
@@ -366,9 +366,9 @@ pseudo_server_start(int daemonize) {
 	if (daemonize) {
 		pid_t ppid = getppid();
 		if (ppid == 1) {
-			pseudo_diag("Setup complete, but parent is init, not sending SIGUSR1.\n");
+			pseudo_info("Setup complete, but parent is init, not sending SIGUSR1.\n");
 		} else {
-			pseudo_diag("Setup complete, sending SIGUSR1 to pid %d.\n",
+			pseudo_info("Setup complete, sending SIGUSR1 to pid %d.\n",
 				ppid);
 			kill(ppid, SIGUSR1);
 		}
@@ -424,7 +424,7 @@ open_client(int fd) {
 		++active_clients;
 		return max_clients - 16;
 	} else {
-		pseudo_diag("error allocating new client, fd %d\n", fd);
+		pseudo_error("error allocating new client, fd %d\n", fd);
 		close(fd);
 		return 0;
 	}
@@ -439,7 +439,7 @@ close_client(int client) {
 		clients[client].pid, clients[client].fd);
 	/* client went away... */
 	if (client > highest_client || client <= 0) {
-		pseudo_diag("tried to close client %d (highest is %d)\n",
+		pseudo_info("tried to close client %d (highest is %d)\n",
 			client, highest_client);
 		return;
 	}
@@ -559,7 +559,7 @@ serve_client(int i) {
 
 				response_path = malloc(8 * active_clients);
 				if (!response_path) {
-					pseudo_diag("out of memory allocating shutdown response\n");
+					pseudo_error("out of memory allocating shutdown response\n");
 					exit(PSEUDO_EXIT_GENERAL);
 				} else {
 					memset(response_path, 0, 8 * active_clients);
@@ -633,7 +633,7 @@ static void pseudo_server_loop_epoll(void)
 
 	clients = malloc(16 * sizeof(*clients));
 	if (!clients) {
-		pseudo_diag("out of memory allocating client table.\n");
+		pseudo_error("out of memory allocating client table.\n");
 		exit(PSEUDO_EXIT_LISTEN_FD);
 	}
 
@@ -655,7 +655,7 @@ static void pseudo_server_loop_epoll(void)
 
 	pseudo_debug(PDBGF_SERVER, "server loop started.\n");
 	if (listen_fd < 0) {
-		pseudo_diag("got into loop with no valid listen fd.\n");
+		pseudo_error("got into loop with no valid listen fd.\n");
 		exit(PSEUDO_EXIT_LISTEN_FD);
 	}
 
@@ -663,13 +663,13 @@ static void pseudo_server_loop_epoll(void)
 
 	int epollfd = epoll_create1(0);
 	if (epollfd == -1) {
-		pseudo_diag("epoll_create1() failed.\n");
+		pseudo_error("epoll_create1() failed.\n");
 		exit(PSEUDO_EXIT_EPOLL_CREATE);
 	}
 	ev.events = EPOLLIN;
 	ev.data.u64 = 0;
 	if (epoll_ctl(epollfd, EPOLL_CTL_ADD, clients[0].fd, &ev) == -1) {
-		pseudo_diag("epoll_ctl() failed with listening socket.\n");
+		pseudo_error("epoll_ctl() failed with listening socket.\n");
 		exit(PSEUDO_EXIT_EPOLL_CTL);
 	}
 
@@ -724,7 +724,7 @@ static void pseudo_server_loop_epoll(void)
 							ev.events = EPOLLIN;
 							ev.data.u64 = open_client(fd);
 							if (ev.data.u64 != 0 && epoll_ctl(epollfd, EPOLL_CTL_ADD, clients[ev.data.u64].fd, &ev) == -1) {
-								pseudo_diag("epoll_ctl() failed with accepted socket.\n");
+								pseudo_error("epoll_ctl() failed with accepted socket.\n");
 								exit(PSEUDO_EXIT_EPOLL_CTL);
 							}
 						} else if (errno == EMFILE) {
@@ -746,22 +746,22 @@ static void pseudo_server_loop_epoll(void)
 			}
 			pseudo_debug(PDBGF_SERVER, "server loop complete [%d clients left]\n", active_clients);
 		} else {
-			pseudo_diag("epoll_wait failed: %s\n", strerror(errno));
+			pseudo_error("epoll_wait failed: %s\n", strerror(errno));
 			break;
 		}
 		if (do_list_clients) {
 			do_list_clients = 0;
-			pseudo_diag("listing clients [1 through %d]:\n", highest_client);
+			pseudo_info("listing clients [1 through %d]:\n", highest_client);
 			for (i = 1; i <= highest_client; ++i) {
 				if (clients[i].fd == -1) {
-					pseudo_diag("client %4d: inactive.\n", i);
+					pseudo_info("client %4d: inactive.\n", i);
 					continue;
 				}
-				pseudo_diag("client %4d: fd %4d, pid %5d, program %s\n",
+				pseudo_info("client %4d: fd %4d, pid %5d, program %s\n",
 					i, clients[i].fd, clients[i].pid,
 					clients[i].program ? clients[i].program : "<unspecified>");
 			}
-			pseudo_diag("done.\n");
+			pseudo_info("done.\n");
 		}
 		if (die_peacefully || die_forcefully) {
 			pseudo_debug(PDBGF_SERVER, "quitting.\n");
@@ -807,7 +807,7 @@ pseudo_server_loop(void) {
 
 	clients = malloc(16 * sizeof(*clients));
 	if (!clients) {
-		pseudo_diag("out of memory allocating client table.\n");
+		pseudo_error("out of memory allocating client table.\n");
 		exit(PSEUDO_EXIT_LISTEN_FD);
 	}
 
@@ -830,7 +830,7 @@ pseudo_server_loop(void) {
 
 	pseudo_debug(PDBGF_SERVER, "server loop started.\n");
 	if (listen_fd < 0) {
-		pseudo_diag("got into loop with no valid listen fd.\n");
+		pseudo_error("got into loop with no valid listen fd.\n");
 		exit(PSEUDO_EXIT_LISTEN_FD);
 	}
 	pdb_log_msg(SEVERITY_INFO, NULL, NULL, NULL, "server started (pid %d)", getpid());
@@ -924,18 +924,18 @@ pseudo_server_loop(void) {
 		}
 		if (do_list_clients) {
 			do_list_clients = 0;
-			pseudo_diag("listing clients [1 through %d]:\n", highest_client);
+			pseudo_info("listing clients [1 through %d]:\n", highest_client);
 			for (i = 1; i <= highest_client; ++i) {
 				if (clients[i].fd == -1) {
-					pseudo_diag("client %4d: inactive.\n", i);
+					pseudo_info("client %4d: inactive.\n", i);
 					continue;
 				}
-				pseudo_diag("client %4d: fd %4d, pid %5d, state %s, program %s\n",
+				pseudo_info("client %4d: fd %4d, pid %5d, state %s, program %s\n",
 					i, clients[i].fd, clients[i].pid,
 					FD_ISSET(clients[i].fd, &reads) ? "R" : "-",
 					clients[i].program ? clients[i].program : "<unspecified>");
 			}
-			pseudo_diag("done.\n");
+			pseudo_info("done.\n");
 		}
 		if (die_peacefully || die_forcefully) {
 			pseudo_debug(PDBGF_SERVER, "quitting.\n");
@@ -981,6 +981,6 @@ pseudo_server_loop(void) {
 		timeout = (struct timeval) { .tv_sec = LOOP_DELAY, .tv_usec = 0 };
 		sigprocmask(SIG_BLOCK, &maskusr2, NULL);
 	}
-	pseudo_diag("select failed: %s\n", strerror(errno));
+	pseudo_error("select failed: %s\n", strerror(errno));
 }
 #endif /* this is the else of #ifdef PSEUDO_EPOLL */
#4 lore raw

PATCH 5/8 pseudo.c: Change pseudo_diag() calls to appropriate macros

In reply to [email protected]

From: Dmitry Sakhonchik <[email protected]>

Implements [YOCTO #12141]

---
 pseudo.c | 100 +++++++++++++++++++++++++++----------------------------
 1 file changed, 50 insertions(+), 50 deletions(-)
pseudo.c +50 -50
index e5fe5cf..11112dd 100644
@@ -105,8 +105,8 @@ main(int argc, char *argv[]) {
 		pseudo_debug(PDBGF_SERVER, "[server %d] can't run daemon with libpseudo in %s\n", getpid(), PRELINK_LIBRARIES);
 		s = pseudo_get_value("PSEUDO_UNLOAD");
 		if (s) {
-			pseudo_diag("pseudo: I can't seem to make %s go away.  Sorry.\n", PRELINK_LIBRARIES);
-			pseudo_diag("pseudo: %s: %s\n", PRELINK_LIBRARIES, ld_env);
+			pseudo_error("pseudo: I can't seem to make %s go away.  Sorry.\n", PRELINK_LIBRARIES);
+			pseudo_error("pseudo: %s: %s\n", PRELINK_LIBRARIES, ld_env);
 			exit(PSEUDO_EXIT_PSEUDO_LOADED);
 		}
 		free(s);
@@ -155,7 +155,7 @@ main(int argc, char *argv[]) {
 		case 'i': /* renumber devices, assuming stable inodes */
 			s = PSEUDO_ROOT_PATH(AT_FDCWD, optarg, 0);
 			if (!s) {
-				pseudo_diag("Can't resolve path '%s'\n", optarg);
+				pseudo_error("Can't resolve path '%s'\n", optarg);
 				usage(EXIT_FAILURE);
 			}
 			opt_i = strdup(s);
@@ -168,7 +168,7 @@ main(int argc, char *argv[]) {
 		case 'm': /* move from... (see also 'M') */
 			s = PSEUDO_ROOT_PATH(AT_FDCWD, optarg, 0);
 			if (!s) {
-				pseudo_diag("Can't resolve move-from path '%s'\n", optarg);
+				pseudo_error("Can't resolve move-from path '%s'\n", optarg);
 				usage(EXIT_FAILURE);
 			}
 			opt_m = strdup(s);
@@ -176,7 +176,7 @@ main(int argc, char *argv[]) {
 		case 'M': /* move to... (see also 'm') */
 			s = PSEUDO_ROOT_PATH(AT_FDCWD, optarg, 0);
 			if (!s) {
-				pseudo_diag("Can't resolve move-to path '%s'\n", optarg);
+				pseudo_error("Can't resolve move-to path '%s'\n", optarg);
 				usage(EXIT_FAILURE);
 			}
 			opt_M = strdup(s);
@@ -184,7 +184,7 @@ main(int argc, char *argv[]) {
 		case 'p': /* passwd file path */
 			s = PSEUDO_ROOT_PATH(AT_FDCWD, optarg, AT_SYMLINK_NOFOLLOW);
 			if (!s) {
-				pseudo_diag("Can't resolve passwd path '%s'\n", optarg);
+				pseudo_error("Can't resolve passwd path '%s'\n", optarg);
 				usage(EXIT_FAILURE);
 			}
 			pseudo_set_value("PSEUDO_PASSWD", s);
@@ -192,7 +192,7 @@ main(int argc, char *argv[]) {
 		case 'P': /* prefix */
 			s = PSEUDO_ROOT_PATH(AT_FDCWD, optarg, AT_SYMLINK_NOFOLLOW);
 			if (!s) {
-				pseudo_diag("Can't resolve prefix path '%s'\n", optarg);
+				pseudo_error("Can't resolve prefix path '%s'\n", optarg);
 				usage(EXIT_FAILURE);
 			}
 			pseudo_set_value("PSEUDO_PREFIX", s);
@@ -201,7 +201,7 @@ main(int argc, char *argv[]) {
 		case 'R':	/* pseudo root path */
 			s = PSEUDO_ROOT_PATH(AT_FDCWD, optarg, AT_SYMLINK_NOFOLLOW);
 			if (!s) {
-				pseudo_diag("Can't resolve root path '%s'\n", optarg);
+				pseudo_error("Can't resolve root path '%s'\n", optarg);
 				usage(EXIT_FAILURE);
 			}
 			pseudo_set_value("PSEUDO_CHROOT", s);
@@ -214,7 +214,7 @@ main(int argc, char *argv[]) {
 		case 't': /* timeout */
 			pseudo_server_timeout = pseudo_strtol_wrapper(optarg, &s, 10);
 			if (*s && !isspace(*s)) {
-				pseudo_diag("Timeout must be an integer value.\n");
+				pseudo_error("Timeout must be an integer value.\n");
 				usage(EXIT_FAILURE);
 			}
 			optptr += snprintf(optptr, pseudo_path_max() - (optptr - opts),
@@ -239,7 +239,7 @@ main(int argc, char *argv[]) {
 			break;
 		case '?':
 		default:
-			pseudo_diag("unknown/invalid argument (option '%c').\n", optopt);
+			pseudo_error("unknown/invalid argument (option '%c').\n", optopt);
 			usage(EXIT_FAILURE);
 			break;
 		}
@@ -250,7 +250,7 @@ main(int argc, char *argv[]) {
 
 	s = pseudo_get_prefix(argv[0]);
 	if (!s) {
-		pseudo_diag("Can't figure out prefix.  Set PSEUDO_PREFIX or invoke with full path.\n");
+		pseudo_error("Can't figure out prefix.  Set PSEUDO_PREFIX or invoke with full path.\n");
 		exit(PSEUDO_EXIT_PSEUDO_PREFIX);
 	}
 	free(s);
@@ -261,29 +261,29 @@ main(int argc, char *argv[]) {
 		pseudo_msg_t *msg;
 		int rc;
 		if (!(opt_m && opt_M)) {
-			pseudo_diag("You cannot move the database without specifying from and to.\n");
+			pseudo_error("You cannot move the database without specifying from and to.\n");
 			exit(EXIT_FAILURE);
 		}
 		if (stat(opt_M, &buf) < 0) {
-			pseudo_diag("stat of '%s' failed: %s\n",
+			pseudo_error("stat of '%s' failed: %s\n",
 				opt_M, strerror(errno));
-			pseudo_diag("The directory the database is being moved to must exist.\n");
+			pseudo_error("The directory the database is being moved to must exist.\n");
 			exit(EXIT_FAILURE);
 		}
 		msg = pseudo_msg_new(0, opt_M);
 		if (!msg) {
-			pseudo_diag("Can't allocate message structure.\n");
+			pseudo_error("Can't allocate message structure.\n");
 			exit(EXIT_FAILURE);
 		}
 		rc = pdb_rename_file(opt_m, msg);
 		free(msg);
 		if (rc < 0) {
-			pseudo_diag("Warning: Database move may have failed.\n");
-			pseudo_diag("To try to restore, you can reverse the move.\n");
-			pseudo_diag("To commit to this anyway, run pseudo -C to check the database.\n");
+			pseudo_warning("Database move may have failed.\n");
+			pseudo_warning("To try to restore, you can reverse the move.\n");
+			pseudo_warning("To commit to this anyway, run pseudo -C to check the database.\n");
 			exit(EXIT_FAILURE);
 		}
-		pseudo_diag("Rename looked okay, running database sanity check.\n");
+		pseudo_info("Rename looked okay, running database sanity check.\n");
 		opt_C = 1;
 	}
 
@@ -292,32 +292,32 @@ main(int argc, char *argv[]) {
 		struct stat buf;
 		pseudo_msg_t *msg;
 		if (stat(opt_i, &buf) < 0) {
-			pseudo_diag("stat of '%s' failed: %s\n",
+			pseudo_error("stat of '%s' failed: %s\n",
 				opt_i, strerror(errno));
-			pseudo_diag("The file used to renumber the database must exist.\n");
+			pseudo_error("The file used to renumber the database must exist.\n");
 			exit(EXIT_FAILURE);
 		}
 		msg = pseudo_msg_new(0, opt_i);
 		if (!msg) {
-			pseudo_diag("Couldn't allocate data structure for path.\n");
+			pseudo_error("Couldn't allocate data structure for path.\n");
 			exit(EXIT_FAILURE);
 		}
 		if (pdb_find_file_path(msg)) {
-			pseudo_diag("Couldn't find a database entry for '%s'.\n", opt_i);
+			pseudo_error("Couldn't find a database entry for '%s'.\n", opt_i);
 			exit(EXIT_FAILURE);
 		}
 		if (buf.st_ino != msg->ino) {
-			pseudo_diag("The database inode entry for '%s' doesn't match; you must use -b.\n",
+			pseudo_error("The database inode entry for '%s' doesn't match; you must use -b.\n",
 				opt_i);
 			exit(EXIT_FAILURE);
 		}
 		rc = pdb_renumber_all(msg->dev, buf.st_dev);
 		free(msg);
 		if (rc < 0) {
-			pseudo_diag("Warning: Database renumber failed.\n");
+			pseudo_warning("Database renumber failed.\n");
 			exit(EXIT_FAILURE);
 		}
-		pseudo_diag("Renumber looked okay, running database sanity check.\n");
+		pseudo_info("Renumber looked okay, running database sanity check.\n");
 		opt_C = 1;
 	}
 
@@ -332,13 +332,13 @@ main(int argc, char *argv[]) {
 	}
 
 	if (opt_d && opt_f) {
-		pseudo_diag("You cannot run a foregrounded daemon.\n");
+		pseudo_error("You cannot run a foregrounded daemon.\n");
 		exit(PSEUDO_EXIT_PSEUDO_INVOCATION);
 	}
 
 	if (opt_f || opt_d) {
 		if (argc > optind) {
-			pseudo_diag("pseudo: running program implies spawning background daemon.\n");
+			pseudo_error("pseudo: running program implies spawning background daemon.\n");
 			exit(PSEUDO_EXIT_PSEUDO_INVOCATION);
 		}
 	} else {
@@ -347,7 +347,7 @@ main(int argc, char *argv[]) {
 
 		if (opt_r) {
 			if (chdir(opt_r) == -1) {
-				pseudo_diag("failed to chdir to '%s': %s\n",
+				pseudo_error("failed to chdir to '%s': %s\n",
 					opt_r, strerror(errno));
 				exit(EXIT_FAILURE);
 			}
@@ -378,7 +378,7 @@ main(int argc, char *argv[]) {
 				int len = strcspn(path, ":");
 				if ( snprintf(fullpath, pseudo_path_max(), "%.*s/%s",
 					len, path, argv[0]) > (int) pseudo_path_max()) {
-					pseudo_diag("pseudo: path too long.\n");
+					pseudo_error("pseudo: path too long.\n");
 					exit(EXIT_FAILURE);
 				}
 				path += len;
@@ -392,7 +392,7 @@ main(int argc, char *argv[]) {
 				}
 			}
 			if (!found) {
-				pseudo_diag("Can't find '%s' in $PATH.\n",
+				pseudo_error("Can't find '%s' in $PATH.\n",
 					argv[0]);
 				exit(EXIT_FAILURE);
 			}
@@ -401,7 +401,7 @@ main(int argc, char *argv[]) {
 
 		rc = fork();
 		if (rc == -1) {
-			pseudo_diag("pseudo: fork failed: %s\n",
+			pseudo_error("pseudo: fork failed: %s\n",
 				strerror(errno));
 			exit(EXIT_FAILURE);
 		} else {
@@ -424,7 +424,7 @@ main(int argc, char *argv[]) {
 			} else {
 				rc = execv(fullpath, argv);
 				if (rc == -1) {
-					pseudo_diag("pseudo: can't run %s: %s\n",
+					pseudo_error("pseudo: can't run %s: %s\n",
 						argv[0], strerror(errno));
 				}
 			}
@@ -615,7 +615,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag, char **respon
 					 */
 					pdb_did_unlink_file(msg->path, NULL, by_path.deleting);
 				} else {
-					pseudo_diag("inode mismatch: '%s' ino %llu in db, %llu in request.\n",
+					pseudo_error("inode mismatch: '%s' ino %llu in db, %llu in request.\n",
 						msg->path,
 						(unsigned long long) by_path.ino,
 						(unsigned long long) msg_header.ino);
@@ -634,14 +634,14 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag, char **respon
 		 * the bogus entry that we noticed.
 		 */
 		if (S_ISDIR(by_path.mode) != S_ISDIR(msg_header.mode)) {
-			pseudo_diag("dir mismatch: '%s' [%llu] db mode 0%o, header mode 0%o (unlinking db)\n",
+			pseudo_error("dir mismatch: '%s' [%llu] db mode 0%o, header mode 0%o (unlinking db)\n",
 				msg->path, (unsigned long long) by_path.ino,
 				(int) by_path.mode, (int) msg_header.mode);
 			/* unlink this path -- the inode may be in use elsewhere */
 			pdb_unlink_file(msg);
 			found_path = 0;
 		} else if (S_ISLNK(by_path.mode) != S_ISLNK(msg_header.mode)) {
-			pseudo_diag("symlink mismatch: '%s' [%llu] db mode 0%o, header mode 0%o (unlinking db)\n",
+			pseudo_error("symlink mismatch: '%s' [%llu] db mode 0%o, header mode 0%o (unlinking db)\n",
 				msg->path, (unsigned long long) by_path.ino,
 				(int) by_path.mode, (int) msg_header.mode);
 			/* unlink this path -- the inode may be in use elsewhere */
@@ -649,7 +649,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag, char **respon
 			found_path = 0;
 		}
 		if (trailing_slash && !S_ISDIR(by_path.mode)) {
-			pseudo_diag("dir quasi-mismatch: '%s' [%llu] db mode 0%o, incoming path had trailing slash. Not unlinking.\n",
+			pseudo_error("dir quasi-mismatch: '%s' [%llu] db mode 0%o, incoming path had trailing slash. Not unlinking.\n",
 				msg->path, (unsigned long long) by_path.ino,
 				(int) by_path.mode);
 		}
@@ -713,7 +713,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag, char **respon
 					pseudo_debug(PDBGF_FILE, "inode mismatch for '%s' -- old one was marked for deletion.\n",
 						msg->path);
 				} else {
-					pseudo_diag("path mismatch [%d link%s]: ino %llu db '%s' req '%s'.\n",
+					pseudo_error("path mismatch [%d link%s]: ino %llu db '%s' req '%s'.\n",
 						msg->nlink,
 						msg->nlink == 1 ? "" : "s",
 						(unsigned long long) msg_header.ino,
@@ -734,7 +734,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag, char **respon
 		 * entry.  There is no way it can be right.
 		 */
 		if (S_ISDIR(by_ino.mode) != S_ISDIR(msg_header.mode)) {
-			pseudo_diag("dir err : %llu ['%s'] (db '%s') db mode 0%o, header mode 0%o (unlinking db)\n",
+			pseudo_error("dir err : %llu ['%s'] (db '%s') db mode 0%o, header mode 0%o (unlinking db)\n",
 				(unsigned long long) msg_header.ino,
 				msg->pathlen ? msg->path : "no path",
 				path_by_ino ? path_by_ino : "no path",
@@ -746,7 +746,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag, char **respon
 			 * can ever be a symlink; the test is generic as
 			 * insurance against forgetting to fix it in a future
 			 * update. */
-			pseudo_diag("symlink err : %llu ['%s'] (db '%s') db mode 0%o, header mode 0%o (unlinking db)\n",
+			pseudo_error("symlink err : %llu ['%s'] (db '%s') db mode 0%o, header mode 0%o (unlinking db)\n",
 				(unsigned long long) msg_header.ino,
 				msg->pathlen ? msg->path : "no path",
 				path_by_ino ? path_by_ino : "no path",
@@ -771,7 +771,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag, char **respon
 	case OP_CLOSE:
 		/* these messages are handled entirely on the client side,
 		 * as of this writing, but might be logged by accident: */
-		pseudo_diag("error: op %s sent to server.\n", pseudo_op_name(msg->op));
+		pseudo_error("op %s sent to server.\n", pseudo_op_name(msg->op));
 		break;
 	case OP_EXEC:		/* FALLTHROUGH */
 	case OP_OPEN:
@@ -785,7 +785,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag, char **respon
 			 * ... But only if it wasn't a match on both inode *and*
 			 * path, because if it were, that would be harmless.
 			 */
-			pseudo_diag("creat for '%s' replaces existing %llu ['%s'].\n",
+			pseudo_info("creat for '%s' replaces existing %llu ['%s'].\n",
 				msg->pathlen ? msg->path : "no path",
 				(unsigned long long) by_ino.ino,
 				path_by_ino ? path_by_ino : "no path");
@@ -797,7 +797,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag, char **respon
 			pdb_link_file(msg);
 		} else {
 			/* again, an error, but leaving it alone for now. */
-			pseudo_diag("creat ignored for existing file '%s'.\n",
+			pseudo_error("creat ignored for existing file '%s'.\n",
 				msg->pathlen ? msg->path : "no path");
 		}
 		break;
@@ -984,7 +984,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag, char **respon
 		 * file DID NOT exist before the call.  Fix database:
 		 */
 		if (found_path) {
-			pseudo_diag("mkdir/mknod: '%s' [%llu] already existed (mode 0%o), unlinking\n",
+			pseudo_info("mkdir/mknod: '%s' [%llu] already existed (mode 0%o), unlinking\n",
 				msg->path, (unsigned long long) by_path.ino,
 				(int) by_path.mode);
 			pdb_unlink_file(msg);
@@ -1035,7 +1035,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag, char **respon
 		pdb_remove_xattr(msg, oldpath, oldpathlen);
 		break;
 	default:
-		pseudo_diag("unknown op from client %d, op %d [%s]\n",
+		pseudo_error("unknown op from client %d, op %d [%s]\n",
 			msg->client, msg->op,
 			msg->pathlen ? msg->path : "no path");
 		break;
@@ -1110,7 +1110,7 @@ pseudo_db_check(int fix) {
 
 	l = pdb_files();
 	if (!l) {
-		pseudo_diag("Couldn't start file list, can't scan.\n");
+		pseudo_error("Couldn't start file list, can't scan.\n");
 		return EXIT_FAILURE;
 	}
 	while ((m = pdb_file(l)) != NULL) {
@@ -1123,7 +1123,7 @@ pseudo_db_check(int fix) {
 			pseudo_debug(PDBGF_DB, "Checking <%s>\n", m->path);
 			if (lstat(m->path, &buf)) {
 				if (!fix) {
-					pseudo_diag("can't stat <%s>\n", m->path);
+					pseudo_error("can't stat <%s>\n", m->path);
 					errors = EXIT_FAILURE;
 					continue;
 				} else {
@@ -1180,7 +1180,7 @@ pseudo_db_check(int fix) {
 						rc = pdb_may_unlink_file(m, magic_cookie);
 					}
 					if (rc) {
-						pseudo_diag("error updating file %s\n",
+						pseudo_error("error updating file %s\n",
 							m->path);
 						errors = EXIT_FAILURE;
 					}
@@ -1195,8 +1195,8 @@ pseudo_db_check(int fix) {
 	if (delete_some) {
 		rc = pdb_did_unlink_files(magic_cookie);
 		if (rc) {
-			pseudo_diag("error nuking mismatched files.\n");
-			pseudo_diag("database may not be fixed.\n");
+			pseudo_error("error nuking mismatched files.\n");
+			pseudo_error("database may not be fixed.\n");
 			errors = EXIT_FAILURE;
 		}
 	}
#5 lore raw

PATCH 6/8 pseudolog.c: Change pseudo_diag() calls to appropriate macros

In reply to [email protected]

From: Dmitry Sakhonchik <[email protected]>

Implements [YOCTO #12141]

---
 pseudolog.c | 76 ++++++++++++++++++++++++++---------------------------
 1 file changed, 38 insertions(+), 38 deletions(-)
pseudolog.c +38 -38
index 44f7dbf..a497eb5 100644
@@ -128,7 +128,7 @@ plog_query_type(char **string) {
 		return PSQT_UNKNOWN;
 	switch (**string) {
 	case '\0':
-		pseudo_diag("Error: Value may not be an empty string.");
+		pseudo_error("Value may not be an empty string.");
 		return PSQT_UNKNOWN;
 		break;
 	case '>':
@@ -170,7 +170,7 @@ plog_query_type(char **string) {
 		break;
 	}
 	if (opt_l && type != PSQT_EXACT) {
-		pseudo_diag("Error: Non-exact match requested while trying to create a log entry.\n");
+		pseudo_error("Non-exact match requested while trying to create a log entry.\n");
 		type = PSQT_UNKNOWN;
 	}
 	return type;
@@ -214,7 +214,7 @@ parse_file_type(char *string) {
 		return S_IFSOCK;
 		break;
 	default:
-		pseudo_diag("unknown file type %c; should be one of [-bcdflps]\n",
+		pseudo_error("unknown file type %c; should be one of [-bcdflps]\n",
 			isprint(*string) ? *string : '?');
 		return -1;
 		break;
@@ -231,7 +231,7 @@ parse_partial_mode(char *string) {
 	case '-':
 		break;
 	default:
-		pseudo_diag("unknown mode character: %c\n", string[0]);
+		pseudo_error("unknown mode character: %c\n", string[0]);
 		return -1;
 		break;
 	}
@@ -242,7 +242,7 @@ parse_partial_mode(char *string) {
 	case '-':
 		break;
 	default:
-		pseudo_diag("unknown mode character: %c\n", string[1]);
+		pseudo_error("unknown mode character: %c\n", string[1]);
 		return -1;
 		break;
 	}
@@ -261,7 +261,7 @@ parse_partial_mode(char *string) {
 	case '-':
 		break;
 	default:
-		pseudo_diag("unknown mode character: %c\n", string[2]);
+		pseudo_error("unknown mode character: %c\n", string[2]);
 		return -1;
 		break;
 	}
@@ -275,14 +275,14 @@ parse_mode_string(char *string) {
 	mode_t bits = 0;
 
 	if (len != 9 && len != 10) {
-		pseudo_diag("mode strings must be of the form [-]rwxr-xr-x\n");
+		pseudo_error("mode strings must be of the form [-]rwxr-xr-x\n");
 		return -1;
 	}
 	if (len == 10) {
 		mode |= parse_file_type(string);
 		++string;
 		if (mode == (mode_t) -1) {
-			pseudo_diag("mode strings with a file type must use a valid type [-bcdflps]\n");
+			pseudo_error("mode strings with a file type must use a valid type [-bcdflps]\n");
 			return -1;
 		}
 	}
@@ -341,14 +341,14 @@ parse_timestamp(char *string) {
 		}
 	}
 	if (!time_formats[i]) {
-		pseudo_diag("Couldn't parse <%s> as a time.  Current time in known formats is:\n",
+		pseudo_error("Couldn't parse <%s> as a time.  Current time in known formats is:\n",
 			string);
 		localtime_r(&stamp_sec, &stamp_tm);
 		for (i = 0; time_formats[i]; ++i) {
 			strftime(timebuf, sizeof(timebuf), time_formats[i], &stamp_tm);
-			pseudo_diag("\t%s\n", timebuf);
+			pseudo_info("\t%s\n", timebuf);
 		}
-		pseudo_diag("Or, specify your own with -E; see strptime(3).\n");
+		pseudo_info("Or, specify your own with -E; see strptime(3).\n");
 		return -1;
 	}
 	return mktime(&stamp_tm);
@@ -360,31 +360,31 @@ plog_trait(int opt, char *string) {
 	char *endptr;
 
 	if (opt < 0 || opt > UCHAR_MAX) {
-		pseudo_diag("Unknown/invalid option value: %d\n", opt);
+		pseudo_error("Unknown/invalid option value: %d\n", opt);
 		return 0;
 	}
 	if (!opt_to_field[opt]) {
 		if (isprint(opt)) {
-			pseudo_diag("Unknown option: -%c\n", opt);
+			pseudo_error("Unknown option: -%c\n", opt);
 		} else {
-			pseudo_diag("Unknown option: 0x%02x\n", opt);
+			pseudo_error("Unknown option: 0x%02x\n", opt);
 		}
 		return 0;
 	}
 	if (!*string) {
-		pseudo_diag("invalid empty string for -%c\n", opt);
+		pseudo_error("invalid empty string for -%c\n", opt);
 		return 0;
 	}
 	new_trait = calloc(1, sizeof(*new_trait));
 	if (!new_trait) {
-		pseudo_diag("Couldn't allocate requested trait (for -%c %s)\n",
+		pseudo_error("Couldn't allocate requested trait (for -%c %s)\n",
 			opt, string ? string : "<nil>");
 		return 0;
 	}
 	new_trait->field = opt_to_field[opt];
 	new_trait->type = plog_query_type(&string);
 	if (new_trait->type == PSQT_UNKNOWN) {
-		pseudo_diag("Couldn't comprehend trait type for '%s'\n",
+		pseudo_error("Couldn't comprehend trait type for '%s'\n",
 			string ? string : "<nil>");
 		free(new_trait);
 		return 0;
@@ -393,7 +393,7 @@ plog_trait(int opt, char *string) {
 	case PSQF_ACCESS:
 		new_trait->data.ivalue = pseudo_access_fopen(string);
 		if (new_trait->data.ivalue == (unsigned long long) -1) {
-			pseudo_diag("access flags should be specified like fopen(3) mode strings (or x for exec).\n");
+			pseudo_error("access flags should be specified like fopen(3) mode strings (or x for exec).\n");
 			free(new_trait);
 			return 0;
 		}
@@ -406,7 +406,7 @@ plog_trait(int opt, char *string) {
 		 * first character is the terminating NUL, we may not
 		 * access the second. */
 		if (string[0] && string[1]) {
-			pseudo_diag("file type must be a single character [-bcdflps].\n");
+			pseudo_error("file type must be a single character [-bcdflps].\n");
 			free(new_trait);
 			return 0;
 		}
@@ -421,13 +421,13 @@ plog_trait(int opt, char *string) {
 		break;
 	case PSQF_ORDER:
 		if (string[0] && string[1]) {
-			pseudo_diag("order type must be a single specifier character.\n");
+			pseudo_error("order type must be a single specifier character.\n");
 			free(new_trait);
 			return 0;
 		}
 		new_trait->data.ivalue = opt_to_field[(unsigned char) string[0]];
 		if (!new_trait->data.ivalue) {
-			pseudo_diag("Unknown field type: %c\n", string[0]);
+			pseudo_error("Unknown field type: %c\n", string[0]);
 		}
 		break;
 	case PSQF_RESULT:
@@ -454,7 +454,7 @@ plog_trait(int opt, char *string) {
 	case PSQF_UID:
 		new_trait->data.ivalue = pseudo_strtoll_wrapper(string, &endptr, 0);
 		if (*endptr) {
-			pseudo_diag("Unexpected garbage after number (%llu): '%s'\n",
+			pseudo_error("Unexpected garbage after number (%llu): '%s'\n",
 				new_trait->data.ivalue, endptr);
 			free(new_trait);
 			return 0;
@@ -485,7 +485,7 @@ plog_trait(int opt, char *string) {
 		new_trait->data.svalue = strdup(string);
 		break;
 	default:
-		pseudo_diag("I don't know how I got here.  Unknown field type %d.\n",
+		pseudo_error("I don't know how I got here.  Unknown field type %d.\n",
 			new_trait->field);
 		free(new_trait);
 		return 0;
@@ -518,7 +518,7 @@ main(int argc, char **argv) {
 		case 'P':
 			s = PSEUDO_ROOT_PATH(AT_FDCWD, optarg, AT_SYMLINK_NOFOLLOW);
 			if (!s)
-				pseudo_diag("Can't resolve prefix path '%s'\n", optarg);
+				pseudo_error("Can't resolve prefix path '%s'\n", optarg);
 			pseudo_set_value("PSEUDO_PREFIX", s);
 			break;
 		case 'v':
@@ -597,12 +597,12 @@ main(int argc, char **argv) {
 	pseudo_debug_flags_finalize();
 
 	if (optind < argc) {
-		pseudo_diag("Error: Extra arguments not associated with any option.\n");
+		pseudo_error("extra arguments not associated with any option.\n");
 		usage(EXIT_FAILURE);
 	}
 
 	if (query_only && opt_l) {
-		pseudo_diag("Error: -l cannot be used with query-only options or flags.\n");
+		pseudo_error("-l cannot be used with query-only options or flags.\n");
 		bad_args = 1;
 	}
 
@@ -611,22 +611,22 @@ main(int argc, char **argv) {
 		exit(EXIT_FAILURE);
 
 	if (!pseudo_get_prefix(argv[0])) {
-		pseudo_diag("Can't figure out prefix.  Set PSEUDO_PREFIX or invoke with full path.\n");
+		pseudo_error("Can't figure out prefix.  Set PSEUDO_PREFIX or invoke with full path.\n");
 		exit(EXIT_FAILURE);
 	}
 
 	if (!pseudo_get_bindir()) {
-		pseudo_diag("Can't figure out bindir.  Set PSEUDO_BINDIR.\n");
+		pseudo_error("Can't figure out bindir.  Set PSEUDO_BINDIR.\n");
 		exit(EXIT_FAILURE);
 	}
 
 	if (!pseudo_get_libdir()) {
-		pseudo_diag("Can't figure out libdir.  Set PSEUDO_LIBDIR.\n");
+		pseudo_error("Can't figure out libdir.  Set PSEUDO_LIBDIR.\n");
 		exit(EXIT_FAILURE);
 	}
 
 	if (!pseudo_get_localstatedir()) {
-		pseudo_diag("Can't figure out localstatedir.  Set PSEUDO_LOCALSTATEDIR.\n");
+		pseudo_error("Can't figure out localstatedir.  Set PSEUDO_LOCALSTATEDIR.\n");
 		exit(EXIT_FAILURE);
 	}
 
@@ -636,12 +636,12 @@ main(int argc, char **argv) {
 		int fields;
 		fields = format_scan(format);
 		if (fields == -1) {
-			pseudo_diag("couldn't parse format string (%s).\n", format);
+			pseudo_error("couldn't parse format string (%s).\n", format);
 			return EXIT_FAILURE;
 		}
 		if (opt_D) {
 			if (pdb_delete(traits, fields)) {
-				pseudo_diag("errors occurred trying to delete entries.\n");
+				pseudo_error("errors occurred trying to delete entries.\n");
 			}
 		} else {
 			history = pdb_history(traits, fields, opt_U);
@@ -653,7 +653,7 @@ main(int argc, char **argv) {
 				}
 				pdb_history_free(history);
 			} else {
-				pseudo_diag("could not retrieve history.\n");
+				pseudo_error("could not retrieve history.\n");
 				return EXIT_FAILURE;
 			}
 		}
@@ -674,12 +674,12 @@ format_one(log_entry *e, char *format) {
 	char *s;
 
 	if (!e || !format) {
-		pseudo_diag("invalid log entry or format specifier.\n");
+		pseudo_error("invalid log entry or format specifier.\n");
 		return 0;
 	}
 	real_len = snprintf(fmtbuf, sizeof(fmtbuf), "%.*s", (int) len + 1, format);
 	if (real_len >= sizeof(fmtbuf) - 1) {
-		pseudo_diag("Format string way too long starting at %.10s",
+		pseudo_error("Format string way too long starting at %.10s",
 			format - 1);
 		return 0;
 	}
@@ -690,7 +690,7 @@ format_one(log_entry *e, char *format) {
 	 * parameters -- this doesn't make sense here.
 	 */
 	if (strchr(fmtbuf, '*') || strchr(fmtbuf, 'l') || strchr(fmtbuf, 'h')) {
-		pseudo_diag("Sorry, you can't use *, h, or l format modifiers.\n");
+		pseudo_error("Sorry, you can't use *, h, or l format modifiers.\n");
 		return 0;
 	}
 
@@ -830,7 +830,7 @@ format_scan(char *format) {
 		len = strcspn(s, "acdfgGimMoprRsStTuy");
 		s += len;
 		if (!*s) {
-			pseudo_diag("Unknown format: '%.3s'\n",
+			pseudo_error("Unknown format: '%.3s'\n",
 				(s - len));
 			return -1;
 		}
@@ -865,7 +865,7 @@ format_scan(char *format) {
 			 */
 			break;
 		default:
-			pseudo_diag("error: invalid format specifier %c (at %s)\n", *s, s);
+			pseudo_error("invalid format specifier %c (at %s)\n", *s, s);
 			return -1;
 			break;
 		}
#6 lore raw

PATCH 7/8 wrappers: Change pseudo_diag() calls to appropriate macros

In reply to [email protected]

From: Dmitry Sakhonchik <[email protected]>

Implements [YOCTO #12141]

---
 ports/darwin/pseudo_wrappers.c      | 3 +--
 ports/linux/guts/fcntl.c            | 2 +-
 ports/linux/guts/fcntl64.c          | 2 +-
 ports/linux/guts/getpw.c            | 2 +-
 ports/linux/guts/openat.c           | 3 +--
 ports/linux/openat2/guts/openat2.c  | 3 +--
 ports/linux/xattr/pseudo_wrappers.c | 3 +--
 ports/unix/guts/getcwd.c            | 6 +++---
 ports/unix/guts/linkat.c            | 2 +-
 ports/unix/guts/nftw_wrapper_base.c | 6 +++---
 ports/unix/guts/symlinkat.c         | 2 +-
 ports/unix/guts/tempnam.c           | 2 +-
 ports/unix/guts/tmpnam.c            | 2 +-
 ports/unix/guts/unlinkat.c          | 2 +-
 pseudo_ipc.c                        | 2 +-
 pseudo_wrappers.c                   | 2 +-
 16 files changed, 20 insertions(+), 24 deletions(-)
ports/darwin/pseudo_wrappers.c +1 -2
index 3f05936..a7a1341 100644
@@ -73,9 +73,8 @@ static int
 posix_permissions(const acl_header *header, int entries, int *extra, int *mode) {
 	int acl_seen = 0;
 	if (le32(header->version) != 2) {
-		pseudo_diag("Fatal: ACL support no available for header version %d.\n",
+		pseudo_critical("ACL support no available for header version %d.\n",
 			le32(header->version));
-		return 1;
 	}
 	*mode = 0;
 	*extra = 0;
ports/linux/guts/fcntl.c +1 -1
index ffb50be..d6babb5 100644
@@ -89,7 +89,7 @@
 		break;
 #endif
 	default:
-		pseudo_diag("unknown fcntl argument %d, assuming long argument.\n",
+		pseudo_error("unknown fcntl argument %d, assuming long argument.\n",
 			cmd);
 		rc = real_fcntl(fd, cmd, arg);
 		break;
ports/linux/guts/fcntl64.c +1 -1
index 99de43d..169fc6d 100644
@@ -89,7 +89,7 @@
 		break;
 #endif
 	default:
-		pseudo_diag("unknown fcntl64 argument %d, assuming long argument.\n",
+		pseudo_error("unknown fcntl64 argument %d, assuming long argument.\n",
 			cmd);
 		rc = real_fcntl64(fd, cmd, arg);
 		break;
ports/linux/guts/getpw.c +1 -1
index 5aa0bca..111799e 100644
@@ -12,7 +12,7 @@
 	static char pwbuf[PSEUDO_PWD_MAX];
 	struct passwd *pwp;
 
-	pseudo_diag("warning: unsafe getpw() called.  hoping buf has at least %d chars.\n",
+	pseudo_warning("unsafe getpw() called.  hoping buf has at least %d chars.\n",
 		PSEUDO_PWD_MAX);
 	rc = wrap_getpwuid_r(uid, &pwd, pwbuf, PSEUDO_PWD_MAX, &pwp);
 	/* different error return conventions */
ports/linux/guts/openat.c +1 -2
index 656ac2b..0a44063 100644
@@ -112,9 +112,8 @@
 		 * stack to stuff that's going to try to drop the lock.
 		 */
 		if (pseudo_getlock()) {
-			pseudo_diag("PANIC: after opening a readonly/writeonly FIFO (path '%s', fd %d, errno %d, saved errno %d), could not regain lock. unrecoverable. sorry. bye.\n",
+			pseudo_critical("after opening a readonly/writeonly FIFO (path '%s', fd %d, errno %d, saved errno %d), could not regain lock. unrecoverable. sorry. bye.\n",
 				path, rc, errno, save_errno);
-			abort();
 		}
 		errno = save_errno;
 	}
ports/linux/openat2/guts/openat2.c +1 -2
index a0acbe7..f1c523e 100644
@@ -147,9 +147,8 @@
 		 * stack to stuff that's going to try to drop the lock.
 		 */
 		if (pseudo_getlock()) {
-			pseudo_diag("PANIC: after opening a readonly/writeonly FIFO (path '%s', fd %d, errno %d, saved errno %d), could not regain lock. unrecoverable. sorry. bye.\n",
+			pseudo_critical("PANIC: after opening a readonly/writeonly FIFO (path '%s', fd %d, errno %d, saved errno %d), could not regain lock. unrecoverable. sorry. bye.\n",
 				pseudo_path, rc, errno, save_errno);
-			abort();
 		}
 		errno = save_errno;
 	}
ports/linux/xattr/pseudo_wrappers.c +1 -2
index 0b65920..896c84d 100644
@@ -66,9 +66,8 @@ static int
 posix_permissions(const acl_header *header, int entries, int *extra, int *mode) {
 	int acl_seen = 0;
 	if (le32(header->version) != 2) {
-		pseudo_diag("Fatal: ACL support not available for header version %d.\n",
+		pseudo_critical("Fatal: ACL support not available for header version %d.\n",
 			le32(header->version));
-		return -1;
 	}
 	*mode = 0;
 	*extra = 0;
ports/unix/guts/getcwd.c +3 -3
index a5bf2ef..f9d6bfc 100644
@@ -11,7 +11,7 @@
 	pseudo_debug(PDBGF_CLIENT, "wrap_getcwd: %p, %lu\n",
 		(void *) buf, (unsigned long) size);
 	if (!pseudo_cwd) {
-		pseudo_diag("Asked for CWD, but don't have it!\n");
+		pseudo_error("Asked for CWD, but don't have it!\n");
 		errno = EACCES;
 		return NULL;
 	}
@@ -33,13 +33,13 @@
 		if (size) {
 			buf = malloc(size);
 		} else {
-			pseudo_diag("can't figure out CWD: length %ld + 1 - %ld => %ld\n",
+			pseudo_error("can't figure out CWD: length %ld + 1 - %ld => %ld\n",
 				(unsigned long) pseudo_cwd_len,
 				(unsigned long) pseudo_chroot_len,
 				(unsigned long) size);
 		}
 		if (!buf) {
-			pseudo_diag("couldn't allocate requested CWD buffer - need %ld byes\n",
+			pseudo_error("couldn't allocate requested CWD buffer - need %ld byes\n",
 				(unsigned long) size);
 			errno = ENOMEM;
 			return NULL;
ports/unix/guts/linkat.c +1 -1
index 60fbf63..ff707c8 100644
@@ -82,7 +82,7 @@
 		rc2 = base_lstat(oldpath, &buf);
 	}
 	if (rc2 == -1) {
-		pseudo_diag("Fatal: Tried to stat '%s' after linking it, but failed: %s.\n",
+		pseudo_error("Fatal: Tried to stat '%s' after linking it, but failed: %s.\n",
 			oldpath, strerror(errno));
 		errno = ENOENT;
 		return rc2;
ports/unix/guts/nftw_wrapper_base.c +3 -3
index 000fa18..b9f761a 100644
@@ -68,7 +68,7 @@ static void NFTW_DELETE_FN_NAME() {
             NFTW_STORAGE_ARRAY_NAME = NULL;
             --NFTW_STORAGE_ARRAY_SIZE;
         } else {
-            pseudo_diag("%s: Invalid callback storage content, can't find corresponding data", __func__);
+            pseudo_error("%s: Invalid callback storage content, can't find corresponding data", __func__);
         }
         return;
     }
@@ -82,7 +82,7 @@ static void NFTW_DELETE_FN_NAME() {
     }
 
     if (found_idx == -1) {
-        pseudo_diag("%s: Invalid callback storage content, can't find corresponding data", __func__);
+        pseudo_error("%s: Invalid callback storage content, can't find corresponding data", __func__);
         return;
     }
 
@@ -102,7 +102,7 @@ static int NFTW_CALLBACK_NAME(const char* fpath, const struct NFTW_STAT_STRUCT _
     struct NFTW_STAT_STRUCT pseudo_sb;
 
     if (!NFTW_FIND_FN_NAME(&saved_details)) {
-        pseudo_diag("%s: Could not find corresponding callback!", __func__);
+        pseudo_error("%s: Could not find corresponding callback!", __func__);
         return -1;
     }
 
ports/unix/guts/symlinkat.c +1 -1
index c96ff3e..5673912 100644
@@ -38,7 +38,7 @@
 #endif
 	if (rc == -1) {
 		int save_errno = errno;
-		pseudo_diag("symlinkat: couldn't stat '%s' even though symlink creation succeeded (%s).\n",
+		pseudo_warning("symlinkat: couldn't stat '%s' even though symlink creation succeeded (%s).\n",
 			newpath, strerror(errno));
 		errno = save_errno;
 		free(roldname);
ports/unix/guts/tempnam.c +1 -1
index 26ae3e1..e2d2c75 100644
@@ -11,7 +11,7 @@
 	/* let gcc know we ignored these on purpose */
 	(void) template;
 	(void) pfx;
-	pseudo_diag("tempnam() is so ludicrously insecure as to defy implementation.");
+	pseudo_warning("tempnam() is so ludicrously insecure as to defy implementation.");
 	errno = ENOMEM;
 	rc = NULL;
 
ports/unix/guts/tmpnam.c +1 -1
index 190d260..60b66e0 100644
@@ -11,7 +11,7 @@
 
 	/* let gcc know we're ignoring this */
 	(void) s;
-	pseudo_diag("tmpnam() is so ludicrously insecure as to defy implementation.");
+	pseudo_warning("tmpnam() is so ludicrously insecure as to defy implementation.");
 	errno = ENOMEM;
 	rc = NULL;
 
ports/unix/guts/unlinkat.c +1 -1
index 7e4f87c..9889b2e 100644
@@ -23,7 +23,7 @@
 		 * with that flag unless the real AT functions exist, so 
 		 * something must have gone horribly wrong....
 		 */
-		pseudo_diag("wrap_unlinkat called with flags (0x%x), path '%s'\n",
+		pseudo_info("wrap_unlinkat called with flags (0x%x), path '%s'\n",
 			rflags, path ? path : "<nil>");
 		errno = ENOSYS;
 		return -1;
pseudo_ipc.c +1 -1
index 838eba2..e51fe0e 100644
@@ -165,7 +165,7 @@ pseudo_msg_receive(int fd) {
 	if (!incoming || header.pathlen >= incoming_pathlen) {
 		newmsg = pseudo_msg_new(header.pathlen + 128, 0);
 		if (!newmsg) {
-			pseudo_diag("Couldn't allocate header for path of %d bytes.\n",
+			pseudo_error("Couldn't allocate header for path of %d bytes.\n",
 				(int) header.pathlen);
 			return 0;
 		}
pseudo_wrappers.c +1 -1
index 9ae1200..662c276 100644
@@ -249,7 +249,7 @@ pseudo_magic() {
 
 static void
 pseudo_enosys(const char *func) {
-	pseudo_diag("pseudo: ENOSYS for '%s'.\n", func ? func : "<nil>");
+	pseudo_info("pseudo: ENOSYS for '%s'.\n", func ? func : "<nil>");
 	char * value = pseudo_get_value("PSEUDO_ENOSYS_ABORT");
 	if (value)
 		abort();
#7 lore raw

PATCH 8/8 pseudo: Change pseudo_diag() name to pseudo_log()

In reply to [email protected]

From: Dmitry Sakhonchik <[email protected]>

Implements [YOCTO #12141]

---
 pseudo.h      | 14 +++++++-------
 pseudo_util.c |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)
pseudo.h +7 -7
index d214ba2..92ae71e 100644
@@ -34,7 +34,7 @@ extern unsigned long pseudo_util_severity_flags;
 extern int pseudo_util_debug_fd;
 extern int pseudo_disabled;
 extern int pseudo_allow_fsync;
-extern int pseudo_diag(char *, ...) __attribute__ ((format (printf, 1, 2)));
+extern int pseudo_log(char *, ...) __attribute__ ((format (printf, 1, 2)));
 extern int pseudo_evlog_internal(char *, ...) __attribute__ ((format (printf, 1, 2)));
 #define pseudo_evlog(x, ...) do { \
 	if (pseudo_util_evlog_flags & (x)) { pseudo_evlog_internal(__VA_ARGS__); } \
@@ -42,27 +42,27 @@ extern int pseudo_evlog_internal(char *, ...) __attribute__ ((format (printf, 1,
 extern void pseudo_evlog_dump(void);
 #ifndef NDEBUG
 #define pseudo_critical(fmt, ...) do { \
-	pseudo_diag("CRITICAL: " fmt, ##__VA_ARGS__); \
+	pseudo_log("CRITICAL: " fmt, ##__VA_ARGS__); \
 	abort(); \
 } while (0)
 #define pseudo_error(fmt, ...) do { \
-	pseudo_diag("ERROR: " fmt, ##__VA_ARGS__); \
+	pseudo_log("ERROR: " fmt, ##__VA_ARGS__); \
 } while (0)
 #define pseudo_warning(fmt, ...) do { \
 	if (pseudo_util_severity_flags & SEVERITYF_WARN) { \
-		pseudo_diag("WARNING: " fmt, ##__VA_ARGS__); \
+		pseudo_log("WARNING: " fmt, ##__VA_ARGS__); \
 	} \
 } while (0)
 #define pseudo_info(fmt, ...) do { \
 	if (pseudo_util_severity_flags & SEVERITYF_INFO) { \
-		pseudo_diag("INFO: " fmt, ##__VA_ARGS__); \
+		pseudo_log("INFO: " fmt, ##__VA_ARGS__); \
 	} \
 } while (0)
 #define pseudo_debug(x, ...) do { \
 	if ((x) & PDBGF_VERBOSE) { \
-		if ((pseudo_util_debug_flags & PDBGF_VERBOSE) && (pseudo_util_debug_flags & ((x) & ~PDBGF_VERBOSE))) { pseudo_diag(__VA_ARGS__); } \
+		if ((pseudo_util_debug_flags & PDBGF_VERBOSE) && (pseudo_util_debug_flags & ((x) & ~PDBGF_VERBOSE))) { pseudo_log(__VA_ARGS__); } \
 	} else { \
-		if ((pseudo_util_debug_flags & (x)) || ((x) == 0)) { pseudo_diag(__VA_ARGS__); } \
+		if ((pseudo_util_debug_flags & (x)) || ((x) == 0)) { pseudo_log(__VA_ARGS__); } \
 	} \
 } while (0) 
 #define pseudo_debug_call(x, fn, ...) do { \
pseudo_util.c +1 -1
index dbd979e..893a25b 100644
@@ -528,7 +528,7 @@ pseudo_debug_clear(char *s) {
 }
 
 int
-pseudo_diag(char *fmt, ...) {
+pseudo_log(char *fmt, ...) {
 	va_list ap;
 	char debuff[8192];
 	int len;