From aec9d7266777e0b9243ef0f112fe0e07256bd446 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 30 Jul 2023 10:30:52 -0700 Subject: Xauth.h: add access & malloc attributes to function prototypes May aid in static analysis by gcc Signed-off-by: Alan Coopersmith --- include/X11/Xauth.h | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/include/X11/Xauth.h b/include/X11/Xauth.h index a51bc72..bd558eb 100644 --- a/include/X11/Xauth.h +++ b/include/X11/Xauth.h @@ -67,12 +67,34 @@ typedef struct xauth { _XFUNCPROTOBEGIN +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with older compilers */ +#endif + +#if __has_attribute(access) +# define XAU_ACCESS_ATTRIBUTE(X) __attribute__((access X)) +#else +# define XAU_ACCESS_ATTRIBUTE(X) +#endif + +#if __has_attribute(malloc) +# define XAU_MALLOC_ATTRIBUTE(X) __attribute__((malloc X)) +#else +# define XAU_MALLOC_ATTRIBUTE(X) +#endif + char *XauFileName(void); +void XauDisposeAuth( +Xauth* /* auth */ +); + +XAU_MALLOC_ATTRIBUTE((XauDisposeAuth, 1)) Xauth *XauReadAuth( FILE* /* auth_file */ ); +XAU_ACCESS_ATTRIBUTE((read_only, 1)) /* file_name */ int XauLockAuth( _Xconst char* /* file_name */, int /* retries */, @@ -80,15 +102,20 @@ int /* timeout */, long /* dead */ ); +XAU_ACCESS_ATTRIBUTE((read_only, 1)) /* file_name */ int XauUnlockAuth( _Xconst char* /* file_name */ ); +XAU_ACCESS_ATTRIBUTE((read_only, 2)) /* auth */ int XauWriteAuth( FILE* /* auth_file */, Xauth* /* auth */ ); +XAU_ACCESS_ATTRIBUTE((read_only, 3, 2)) /* address */ +XAU_ACCESS_ATTRIBUTE((read_only, 5, 4)) /* number */ +XAU_ACCESS_ATTRIBUTE((read_only, 7, 6)) /* name */ Xauth *XauGetAuthByAddr( #if NeedWidePrototypes unsigned int /* family */, @@ -112,6 +139,10 @@ unsigned short /* name_length */, _Xconst char* /* name */ ); +XAU_ACCESS_ATTRIBUTE((read_only, 3, 2)) /* address */ +XAU_ACCESS_ATTRIBUTE((read_only, 5, 4)) /* number */ +XAU_ACCESS_ATTRIBUTE((read_only, 7, 6)) /* type_names */ +XAU_ACCESS_ATTRIBUTE((read_only, 8, 6)) /* type_lengths */ Xauth *XauGetBestAuthByAddr( #if NeedWidePrototypes unsigned int /* family */, @@ -132,10 +163,6 @@ char** /* type_names */, _Xconst int* /* type_lengths */ ); -void XauDisposeAuth( -Xauth* /* auth */ -); - _XFUNCPROTOEND /* Return values from XauLockAuth */ -- cgit v1.2.3