[PATCH rtems-libbsd master 2/3] rtemsbsd/rtems: Check function return values

Kinsey Moore kinsey.moore at oarcorp.com
Tue Jan 23 21:53:10 UTC 2024


---
 rtemsbsd/rtems/rtems-bsd-rc-conf-net.c | 10 ++++++----
 rtemsbsd/rtems/rtems-kernel-init.c     |  4 +++-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/rtemsbsd/rtems/rtems-bsd-rc-conf-net.c b/rtemsbsd/rtems/rtems-bsd-rc-conf-net.c
index 23ee15db..8ffaa914 100644
--- a/rtemsbsd/rtems/rtems-bsd-rc-conf-net.c
+++ b/rtemsbsd/rtems/rtems-bsd-rc-conf-net.c
@@ -103,7 +103,9 @@ cloned_interfaces(rtems_bsd_rc_conf* rc_conf, rtems_bsd_rc_conf_argc_argv* aa)
       "ifconfig", aa->argv[arg], "create", NULL
     };
     rtems_bsd_rc_conf_print_cmd(rc_conf, "cloning_interfaces", 3, ifconfg_args);
-    rtems_bsd_command_ifconfig(3, (char**) ifconfg_args);
+    if (rtems_bsd_command_ifconfig(3, (char**) ifconfg_args)) {
+      return -1;
+    }
   }
 
   return 0;
@@ -377,7 +379,7 @@ defaultrouter(rtems_bsd_rc_conf* rc_conf, rtems_bsd_rc_conf_argc_argv* aa, bool
       memset(&sin, 0, sizeof(sin));
       memset(&rti_info[0], 0, sizeof(rti_info));
       sin.sin_family = AF_INET;
-      inet_pton(AF_INET, "0.0.0.0", &sin.sin_addr);
+      (void) inet_pton(AF_INET, "0.0.0.0", &sin.sin_addr);
 
       r = rtems_get_route(&sin, rti_info);
       if (r == 0 && rti_info[RTAX_GATEWAY] != NULL) {
@@ -710,9 +712,9 @@ run_dhcp(rtems_bsd_rc_conf* rc_conf, rtems_bsd_rc_conf_argc_argv* aa)
   }
   dd->config.priority = priority;
 
-  rtems_bsd_rc_conf_find(rc_conf, "dhcpcd_options", dd->argc_argv);
+  r = rtems_bsd_rc_conf_find(rc_conf, "dhcpcd_options", dd->argc_argv);
 
-  if (dd->argc_argv->argc > 0) {
+  if (r == 0 && dd->argc_argv->argc > 0) {
     dd->config.argc = dd->argc_argv->argc;
     dd->config.argv = dd->argc_argv->argv;
   }
diff --git a/rtemsbsd/rtems/rtems-kernel-init.c b/rtemsbsd/rtems/rtems-kernel-init.c
index 7112914e..b0779277 100644
--- a/rtemsbsd/rtems/rtems-kernel-init.c
+++ b/rtemsbsd/rtems/rtems-kernel-init.c
@@ -135,7 +135,9 @@ rtems_bsd_initialize(void)
 	sbt_tickthreshold = bttosbt(bt_tickthreshold);
 	maxid_maxcpus = (int) rtems_scheduler_get_processor_maximum();
 
-	mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO);
+	if (mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO) != 0) {
+		return RTEMS_UNSATISFIED;
+	}
 
 	sc =  rtems_timer_initiate_server(
 		rtems_bsd_get_task_priority(name),
-- 
2.39.2



More information about the devel mailing list