NetBSD-Docs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

envsys(4): patch for example code



The example given in envsys(4) needs to be updated in order to compile
and run without errors/leaks on:

$ uname -a
NetBSD x202e.localdomain 9.99.81 NetBSD 9.99.81 (GENERIC) #0: Tue Apr 6 15:55:26 UTC 2021 mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64

Patch follows:

---START---
--- examp.c.orig	2021-05-04 06:33:29.465160245 +0000
+++ examp.c	2021-05-04 06:36:26.921900433 +0000
@@ -13,7 +13,7 @@
         if (!prop_dictionary_set(global_dict, "aibs0", array))
                 err(EINVAL, "prop_dictionary_set global");

-        obj = prop_string_create_cstring_nocopy("sensor0");
+        obj = prop_string_create_nocopy("sensor0");
         if (obj == NULL ||
             !prop_dictionary_set(sensor_dict, "index", obj))
                 err(EINVAL, "sensor index");
@@ -31,7 +31,7 @@
         if (!prop_array_add(array, sensor_dict))
                 err(EINVAL, "prop_array_add");

-        if ((fd = open(_DEV_SYSMON, O_RDWR)) == -1)
+        if ((fd = open(_PATH_SYSMON, O_RDWR)) == -1)
                 err(EXIT_FAILURE, "open");

         /* we are done, send the dictionary */
@@ -39,6 +39,7 @@
                                            fd,
                                            ENVSYS_SETDICTIONARY);
         prop_object_release(array);
+        prop_object_release(sensor_dict);
         prop_object_release(global_dict);
         (void)close(fd);
         return error;
---END---

Thanks,
-RVP


Home | Main Index | Thread Index | Old Index