# HG changeset patch # User Pádraig Brady # Date 1417829297 0 # Node ID 5ca75b20ebc24c75ae74c40a5f1d931b9ec59d68 # Parent 2c202161ad79e6462b2134ab60b2c284a12cf25b apply _GL_ATTRIBUTE_PURE to some inline functions clang 3.4.2 flagged these inline functions as pure * lib/savewd.h (savewd_errno): Set _GL_ATTRIBUTE_PURE. * lib/sig-handler.h (get_handler): Likewise. * lib/stat-time.h (get_stat_{a,c,m,birth}time{,_ns}): Likewise. * lib/timespec.h (timespec_cmp, timespec_sign): Likewise. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014-12-08 Pádraig Brady + + apply _GL_ATTRIBUTE_PURE to some inline functions + clang 3.4.2 flagged these inline functions as pure + * lib/savewd.h (savewd_errno): Set _GL_ATTRIBUTE_PURE. + * lib/sig-handler.h (get_handler): Likewise. + * lib/stat-time.h (get_stat_{a,c,m,birth}time{,_ns}): Likewise. + * lib/timespec.h (timespec_cmp, timespec_sign): Likewise. + 2014-12-06 Pádraig Brady vasnprintf: fix potential use after free diff --git a/lib/savewd.h b/lib/savewd.h --- a/lib/savewd.h +++ b/lib/savewd.h @@ -125,7 +125,7 @@ int savewd_restore (struct savewd *wd, int status); /* Return WD's error number, or 0 if WD is not in an error state. */ -SAVEWD_INLINE int +SAVEWD_INLINE int _GL_ATTRIBUTE_PURE savewd_errno (struct savewd const *wd) { return (wd->state == ERROR_STATE ? wd->val.errnum : 0); diff --git a/lib/sig-handler.h b/lib/sig-handler.h --- a/lib/sig-handler.h +++ b/lib/sig-handler.h @@ -34,7 +34,7 @@ /* Return the handler of a signal, as a sa_handler_t value regardless of its true type. The resulting function can be compared to special values like SIG_IGN but it is not portable to call it. */ -SIG_HANDLER_INLINE sa_handler_t +SIG_HANDLER_INLINE sa_handler_t _GL_ATTRIBUTE_PURE get_handler (struct sigaction const *a) { #ifdef SA_SIGINFO diff --git a/lib/stat-time.h b/lib/stat-time.h --- a/lib/stat-time.h +++ b/lib/stat-time.h @@ -54,7 +54,7 @@ #endif /* Return the nanosecond component of *ST's access time. */ -_GL_STAT_TIME_INLINE long int +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE get_stat_atime_ns (struct stat const *st) { # if defined STAT_TIMESPEC @@ -67,7 +67,7 @@ } /* Return the nanosecond component of *ST's status change time. */ -_GL_STAT_TIME_INLINE long int +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE get_stat_ctime_ns (struct stat const *st) { # if defined STAT_TIMESPEC @@ -80,7 +80,7 @@ } /* Return the nanosecond component of *ST's data modification time. */ -_GL_STAT_TIME_INLINE long int +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE get_stat_mtime_ns (struct stat const *st) { # if defined STAT_TIMESPEC @@ -93,7 +93,7 @@ } /* Return the nanosecond component of *ST's birth time. */ -_GL_STAT_TIME_INLINE long int +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE get_stat_birthtime_ns (struct stat const *st) { # if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC @@ -108,7 +108,7 @@ } /* Return *ST's access time. */ -_GL_STAT_TIME_INLINE struct timespec +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE get_stat_atime (struct stat const *st) { #ifdef STAT_TIMESPEC @@ -122,7 +122,7 @@ } /* Return *ST's status change time. */ -_GL_STAT_TIME_INLINE struct timespec +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE get_stat_ctime (struct stat const *st) { #ifdef STAT_TIMESPEC @@ -136,7 +136,7 @@ } /* Return *ST's data modification time. */ -_GL_STAT_TIME_INLINE struct timespec +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE get_stat_mtime (struct stat const *st) { #ifdef STAT_TIMESPEC @@ -151,7 +151,7 @@ /* Return *ST's birth time, if available; otherwise return a value with tv_sec and tv_nsec both equal to -1. */ -_GL_STAT_TIME_INLINE struct timespec +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE get_stat_birthtime (struct stat const *st) { struct timespec t; diff --git a/lib/timespec.h b/lib/timespec.h --- a/lib/timespec.h +++ b/lib/timespec.h @@ -74,7 +74,7 @@ The (int) cast avoids a gcc -Wconversion warning. */ -_GL_TIMESPEC_INLINE int +_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE timespec_cmp (struct timespec a, struct timespec b) { return (a.tv_sec < b.tv_sec ? -1 @@ -84,7 +84,7 @@ /* Return -1, 0, 1, depending on the sign of A. A.tv_nsec must be nonnegative. */ -_GL_TIMESPEC_INLINE int +_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE timespec_sign (struct timespec a) { return a.tv_sec < 0 ? -1 : a.tv_sec || a.tv_nsec;