OK thanks here is the 3rd version with exactly that sprinkled everywhere necessary.
Thanks, Milos On Sun, Apr 12, 2026 at 4:13 PM Samuel Thibault <[email protected]> wrote: > Milos Nikic, le dim. 12 avril 2026 16:09:02 -0700, a ecrit: > > Here is v2 with the actions pulled out of the asserts so they survive > release > > builds. > > How does this look? > > > @@ -150,7 +150,10 @@ diskfs_start_bootstrap (void) > > Hurd server bootstrap: bootfs[bootdev] exec ourfs > > */ > > printf ("\nContinuing on new root filesystem %s:", > diskfs_disk_name); > > - fflush (stdout); > > + if (fflush (stdout) != 0) > > + { > > + assert_backtrace (0); > > "0" in the assertion message won't be that much expressive. Better store > the result in a variable, and assert_backtrace(res == 0). > > Samuel >
From fb98ff90bfb78e7d43446e8e4f55aef1b577b48f Mon Sep 17 00:00:00 2001 From: Milos Nikic <[email protected]> Date: Sun, 12 Apr 2026 15:43:49 -0700 Subject: [PATCH] libdiskfs: Cleanup of boot-start.c Added assertions to calls to fflush and getc, removed an unused include and added one new. --- libdiskfs/boot-start.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c index be47e1b8..5faa1f33 100644 --- a/libdiskfs/boot-start.c +++ b/libdiskfs/boot-start.c @@ -20,6 +20,7 @@ /* Written by Michael I. Bushnell. */ +#include <assert-backtrace.h> #include "priv.h" #include <stdio.h> #include <hurd.h> @@ -33,7 +34,6 @@ #include <string.h> #include <argz.h> #include <error.h> -#include "exec_S.h" #include "exec_startup_S.h" #include "fsys_S.h" #include "fsys_reply_U.h" @@ -105,6 +105,8 @@ diskfs_start_bootstrap (void) mach_port_t fdarray[3]; /* XXX */ task_t newt; error_t err; + int res = 0; + char *exec_argv, *exec_env; const char *initname; size_t exec_argvlen, exec_envlen; @@ -150,7 +152,8 @@ diskfs_start_bootstrap (void) Hurd server bootstrap: bootfs[bootdev] exec ourfs */ printf ("\nContinuing on new root filesystem %s:", diskfs_disk_name); - fflush (stdout); + res = fflush (stdout); + assert_backtrace (res == 0); } else { @@ -159,7 +162,8 @@ diskfs_start_bootstrap (void) printf ("Hurd server bootstrap: %s[%s]", program_invocation_short_name, diskfs_disk_name); - fflush (stdout); + res = fflush (stdout); + assert_backtrace (res == 0); /* Get the execserver going and wait for its fsys_startup */ pthread_mutex_init (&execstartlock, NULL); @@ -270,7 +274,8 @@ diskfs_start_bootstrap (void) { printf ("\nCannot find startup program `%s': %s\n", initname, strerror (err)); - fflush (stdout); + res = fflush (stdout); + assert_backtrace (res == 0); free (exec_argv); assert_perror_backtrace (err); /* XXX this won't reboot properly */ } @@ -307,11 +312,14 @@ diskfs_start_bootstrap (void) if (_diskfs_boot_pause) { printf ("pausing for %s...\n", exec_argv); - fflush (stdout); - getc (stdin); + res = fflush (stdout); + assert_backtrace (res == 0); + res = getc (stdin); + assert_backtrace (res != EOF); } printf (" %s", basename (exec_argv)); - fflush (stdout); + res = fflush (stdout); + assert_backtrace (res == 0); err = exec_exec (diskfs_exec, startup_pt, MACH_MSG_TYPE_COPY_SEND, newt, 0, (data_t)exec_argv, exec_argvlen, (data_t)exec_env, exec_envlen, fdarray, MACH_MSG_TYPE_COPY_SEND, 3, @@ -680,6 +688,7 @@ start_execserver (void) mach_port_t right; extern task_t diskfs_exec_server_task; /* Set in opts-std-startup.c. */ struct port_info *execboot_info; + int res = 0; assert_backtrace (diskfs_exec_server_task != MACH_PORT_NULL); @@ -696,12 +705,16 @@ start_execserver (void) if (_diskfs_boot_pause) { printf ("pausing for exec\n"); - fflush (stdout); - getc (stdin); + res = fflush (stdout); + assert_backtrace (res == 0); + res = getc (stdin); + assert_backtrace (res != EOF); } err = task_resume (diskfs_exec_server_task); assert_perror_backtrace (err); printf (" exec"); - fflush (stdout); + + res = fflush (stdout); + assert_backtrace (res == 0); } -- 2.53.0
