]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
mlock, mlock2, munlock: Tell the compiler we don't dereference the pointer
authorXi Ruoyao <xry111@xry111.site>
Thu, 26 Dec 2024 04:51:18 +0000 (12:51 +0800)
committerAndreas K. Hüttel <dilfridge@gentoo.org>
Wed, 1 Jan 2025 15:08:36 +0000 (16:08 +0100)
Since https://gcc.gnu.org/r11-959, the compiler emits
-Wmaybe-uninitialized if a const pointer to an uninitialized buffer is
passed.  Tell the compiler we don't dereference the pointer to remove
the false alarm.

Link: https://gcc.gnu.org/PR118194
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Sam James <sam@gentoo.org>
misc/sys/mman.h
sysdeps/unix/sysv/linux/bits/mman-shared.h

index c68a85d14077365fc1696a50588a20314da134fa..ae8cee331189d914465f217875d149f1cb22dfeb 100644 (file)
@@ -100,10 +100,12 @@ extern int posix_madvise (void *__addr, size_t __len, int __advice) __THROW;
 
 /* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to
    be memory resident.  */
-extern int mlock (const void *__addr, size_t __len) __THROW;
+extern int mlock (const void *__addr, size_t __len) __THROW
+    __attr_access ((__none__, 1));
 
 /* Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN).  */
-extern int munlock (const void *__addr, size_t __len) __THROW;
+extern int munlock (const void *__addr, size_t __len) __THROW
+    __attr_access ((__none__, 1));
 
 /* Cause all currently mapped pages of the process to be memory resident
    until unlocked by a call to the `munlockall', until the process exits,
index 7a9874204db5e0a8d7fe8585b36c0bf76b4bf2cb..d601bd0e8feba73863647e8ac14f747beb9cde04 100644 (file)
@@ -56,7 +56,8 @@ int memfd_create (const char *__name, unsigned int __flags) __THROW;
 
 /* Lock pages from ADDR (inclusive) to ADDR + LENGTH (exclusive) into
    memory.  FLAGS is a combination of the MLOCK_* flags above.  */
-int mlock2 (const void *__addr, size_t __length, unsigned int __flags) __THROW;
+int mlock2 (const void *__addr, size_t __length, unsigned int __flags) __THROW
+    __attr_access ((__none__, 1));
 
 /* Allocate a new protection key, with the PKEY_DISABLE_* bits
    specified in ACCESS_RESTRICTIONS.  The protection key mask for the