]> sourceware.org Git - lvm2.git/commitdiff
Use expected union semun for arguments in selected semaphore operations.
authorPeter Rajnoha <prajnoha@redhat.com>
Thu, 27 May 2010 15:02:56 +0000 (15:02 +0000)
committerPeter Rajnoha <prajnoha@redhat.com>
Thu, 27 May 2010 15:02:56 +0000 (15:02 +0000)
This is standard and expected use. It also prevents errors related with
misalignment of the arguments for semaphore operations on some architectures.

WHATS_NEW_DM
libdm/libdm-common.c

index 9147c00dd2994db03c3864c6f2598112c04ba814..0ec5d1b7f707fb8d68d0d78e1a1e80819868e31e 100644 (file)
@@ -1,5 +1,6 @@
 Version 1.02.49 - 
 ================================
+  Use expected union semun for arguments in selected semaphore operations.
 
 Version 1.02.48 - 17th May 2010
 ================================
index 9ae2855b4eb67b717b6810763afcc632abaa62e4..03280354325ed34e7f6063855fe24620671787ab 100644 (file)
 
 #define DEV_DIR "/dev/"
 
+#ifdef UDEV_SYNC_SUPPORT
+#ifdef _SEM_SEMUN_UNDEFINED
+union semun
+{
+       int val;                        /* value for SETVAL */
+       struct semid_ds *buf;           /* buffer for IPC_STAT & IPC_SET */
+       unsigned short int *array;      /* array for GETALL & SETALL */
+       struct seminfo *__buf;          /* buffer for IPC_INFO */
+};
+#endif
+#endif
+
 static char _dm_dir[PATH_MAX] = DEV_DIR DM_DIR;
 
 static int _verbose = 0;
@@ -1076,6 +1088,7 @@ static int _udev_notify_sem_create(uint32_t *cookie, int *semid)
        int gen_semid;
        uint16_t base_cookie;
        uint32_t gen_cookie;
+       union semun sem_arg;
 
        if ((fd = open("/dev/urandom", O_RDONLY)) < 0) {
                log_error("Failed to open /dev/urandom "
@@ -1123,7 +1136,9 @@ static int _udev_notify_sem_create(uint32_t *cookie, int *semid)
        log_debug("Udev cookie 0x%" PRIx32 " (semid %d) created",
                  gen_cookie, gen_semid);
 
-       if (semctl(gen_semid, 0, SETVAL, 1) < 0) {
+       sem_arg.val = 1;
+
+       if (semctl(gen_semid, 0, SETVAL, sem_arg) < 0) {
                log_error("semid %d: semctl failed: %s", gen_semid, strerror(errno));
                /* We have to destroy just created semaphore
                 * so it won't stay in the system. */
This page took 0.040656 seconds and 5 git commands to generate.