All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Hatle <mark.hatle@kernel.crashing.org>
To: yocto-patches@lists.yoctoproject.org
Cc: richard.purdie@linuxfoundation.org, frezidok1@gmail.com
Subject: [pseudo][PATCH 07/23] pseudo_server: Change pseudo_diag() calls to appropriate macros
Date: Thu,  2 Jul 2026 19:46:02 -0500	[thread overview]
Message-ID: <1783039578-31531-8-git-send-email-mark.hatle@kernel.crashing.org> (raw)
In-Reply-To: <1783039578-31531-1-git-send-email-mark.hatle@kernel.crashing.org>

From: Dmitry Sakhonchik <frezidok1@gmail.com>

Implements [YOCTO #12141]

Signed-off-by: Dmitry Sakhonchik <frezidok1@gmail.com>
Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
---
 pseudo_server.c | 92 ++++++++++++++++++++++++-------------------------
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/pseudo_server.c b/pseudo_server.c
index edfbce1..c1a97c8 100644
--- a/pseudo_server.c
+++ b/pseudo_server.c
@@ -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 */
-- 
2.53.0



  parent reply	other threads:[~2026-07-03  0:46 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03  0:45 [pseudo][PATCH 00/23] Create new pseudo 1.99.0 version Mark Hatle
2026-07-03  0:45 ` [pseudo][PATCH 01/23] Makefile.in: Move version to 1.99.0 to prep for 2.0 development Mark Hatle
2026-07-03  0:45 ` [pseudo][PATCH 02/23] pseudo_util: Add log severity flags Mark Hatle
2026-07-03  0:45 ` [pseudo][PATCH 03/23] pseudo: Add new logging macros Mark Hatle
2026-07-03  0:45 ` [pseudo][PATCH 04/23] pseudo_util: Change pseudo_diag() calls to appropriate " Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 05/23] pseudo_db: Change pseudo_diag() calls to appropriate macros Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 06/23] pseudo_client: " Mark Hatle
2026-07-03  0:46 ` Mark Hatle [this message]
2026-07-03  0:46 ` [pseudo][PATCH 08/23] pseudo.c: " Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 09/23] pseudolog.c: " Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 10/23] wrappers: " Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 11/23] pseudo: Change pseudo_diag() name to pseudo_log() Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 12/23] pseudo_util: Add default log severity values Mark Hatle
2026-07-03 10:43   ` [yocto-patches] " Paul Barker
2026-07-03 12:44     ` Dmitry Sakhonchik
2026-07-03  0:46 ` [pseudo][PATCH 13/23] pseudo_util.c: strchr now returns const char Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 14/23] test/test-openat2-func.c: Remove unusuaed saved_errno Mark Hatle
2026-07-03 10:44   ` [yocto-patches] " Paul Barker
2026-07-03  0:46 ` [pseudo][PATCH 15/23] pseudo.h: Avoid accessing unallocated memory Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 16/23] pseudo_util: Avoid accidental free calls for without_libpseudo() Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 17/23] pseudo_util: Ensure pseudo_setupenvp handles memory consistently Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 18/23] pseudo_util: Avoid a memory leak in pseudo_dropenv() Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 19/23] pseudo_util: Clean up memory handling for setupenvp results Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 20/23] exec*: Replace bash workaround to avoid memory corruption Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 21/23] pseudo_util: Correctly free memory allocated by pseudo_setupenvp Mark Hatle
2026-07-03  0:46 ` [pseudo][PATCH 22/23] test-bash-exec-env: Add bash env test case Mark Hatle
2026-07-03 11:13   ` [yocto-patches] " Paul Barker
2026-07-03  0:46 ` [pseudo][PATCH 23/23] test: various: Move to makefile compilation Mark Hatle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1783039578-31531-8-git-send-email-mark.hatle@kernel.crashing.org \
    --to=mark.hatle@kernel.crashing.org \
    --cc=frezidok1@gmail.com \
    --cc=richard.purdie@linuxfoundation.org \
    --cc=yocto-patches@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.