[Libguestfs] [libnbd PATCH v3 03/29] socket activation: rename sa_(tmpdir|sockpath) to sact_(tmpdir|sockpath)

Laszlo Ersek lersek at redhat.com
Wed Feb 15 14:11:32 UTC 2023


<signal.h> in POSIX reserves the "sa_" prefix:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_02_02

Let's use "sact_" instead.

Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
 lib/internal.h                               |  4 ++--
 generator/states-connect-socket-activation.c | 16 ++++++++--------
 lib/handle.c                                 | 12 ++++++------
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/internal.h b/lib/internal.h
index c5827f4f0037..0b5f793011b8 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -278,8 +278,8 @@ struct nbd_handle {
   /* When using systemd socket activation, this directory and socket
    * must be deleted, and the pid above must be killed.
    */
-  char *sa_tmpdir;
-  char *sa_sockpath;
+  char *sact_tmpdir;
+  char *sact_sockpath;
 
   /* When connecting to TCP ports, these fields are used. */
   char *hostname, *port;
diff --git a/generator/states-connect-socket-activation.c b/generator/states-connect-socket-activation.c
index 9a83834915db..7138e7638e30 100644
--- a/generator/states-connect-socket-activation.c
+++ b/generator/states-connect-socket-activation.c
@@ -111,22 +111,22 @@  CONNECT_SA.START:
    * short enough to store in the sockaddr_un.  On some platforms this
    * may cause problems so we may need to revisit it.  XXX
    */
-  h->sa_tmpdir = strdup ("/tmp/libnbdXXXXXX");
-  if (h->sa_tmpdir == NULL) {
+  h->sact_tmpdir = strdup ("/tmp/libnbdXXXXXX");
+  if (h->sact_tmpdir == NULL) {
     SET_NEXT_STATE (%.DEAD);
     set_error (errno, "strdup");
     return 0;
   }
-  if (mkdtemp (h->sa_tmpdir) == NULL) {
+  if (mkdtemp (h->sact_tmpdir) == NULL) {
     SET_NEXT_STATE (%.DEAD);
     set_error (errno, "mkdtemp");
     /* Avoid cleanup in nbd_close. */
-    free (h->sa_tmpdir);
-    h->sa_tmpdir = NULL;
+    free (h->sact_tmpdir);
+    h->sact_tmpdir = NULL;
     return 0;
   }
 
-  if (asprintf (&h->sa_sockpath, "%s/sock", h->sa_tmpdir) == -1) {
+  if (asprintf (&h->sact_sockpath, "%s/sock", h->sact_tmpdir) == -1) {
     SET_NEXT_STATE (%.DEAD);
     set_error (errno, "strdup");
     return 0;
@@ -140,10 +140,10 @@  CONNECT_SA.START:
   }
 
   addr.sun_family = AF_UNIX;
-  memcpy (addr.sun_path, h->sa_sockpath, strlen (h->sa_sockpath) + 1);
+  memcpy (addr.sun_path, h->sact_sockpath, strlen (h->sact_sockpath) + 1);
   if (bind (s, (struct sockaddr *) &addr, sizeof addr) == -1) {
     SET_NEXT_STATE (%.DEAD);
-    set_error (errno, "bind: %s", h->sa_sockpath);
+    set_error (errno, "bind: %s", h->sact_sockpath);
     close (s);
     return 0;
   }
diff --git a/lib/handle.c b/lib/handle.c
index 4a186f8fa946..dfd8c2e5cdb9 100644
--- a/lib/handle.c
+++ b/lib/handle.c
@@ -141,15 +141,15 @@ nbd_close (struct nbd_handle *h)
   free_cmd_list (h->cmds_done);
   string_vector_iter (&h->argv, (void *) free);
   free (h->argv.ptr);
-  if (h->sa_sockpath) {
+  if (h->sact_sockpath) {
     if (h->pid > 0)
       kill (h->pid, SIGTERM);
-    unlink (h->sa_sockpath);
-    free (h->sa_sockpath);
+    unlink (h->sact_sockpath);
+    free (h->sact_sockpath);
   }
-  if (h->sa_tmpdir) {
-    rmdir (h->sa_tmpdir);
-    free (h->sa_tmpdir);
+  if (h->sact_tmpdir) {
+    rmdir (h->sact_tmpdir);
+    free (h->sact_tmpdir);
   }
   free (h->hostname);
   free (h->port);



More information about the Libguestfs mailing list