From: Pádraig Brady
Date: Sat, 6 Dec 2014 01:28:17 +0000 (+0000) Subject: apply _GL_ATTRIBUTE_PURE to some inline functions X-Git-Tag: v1.0~7238 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=3c411c43e5bd964fa6ac98f9cca639d18523ff06;p=gnulib.git 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 index 41207ea73e..75b8eacf6c 100644 --- 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 index cd0817b7ce..4d2d7d6dbc 100644 --- a/lib/savewd.h +++ b/lib/savewd.h @@ -125,7 +125,7 @@ int savewd_chdir (struct savewd *wd, char const *dir, int options, 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 index f4fe7eca87..3af1a91c5b 100644 --- a/lib/sig-handler.h +++ b/lib/sig-handler.h @@ -34,7 +34,7 @@ typedef void (*sa_handler_t) (int); /* 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 index b3df6eb816..9cbf8e044d 100644 --- a/lib/stat-time.h +++ b/lib/stat-time.h @@ -54,7 +54,7 @@ _GL_INLINE_HEADER_BEGIN #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 @@ get_stat_atime_ns (struct stat const *st) } /* 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 @@ get_stat_ctime_ns (struct stat const *st) } /* 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 @@ get_stat_mtime_ns (struct stat const *st) } /* 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 @@ get_stat_birthtime_ns (struct stat const *st) } /* 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 @@ get_stat_atime (struct stat const *st) } /* 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 @@ get_stat_ctime (struct stat const *st) } /* 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 @@ get_stat_mtime (struct stat const *st) /* 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 index 872cbb76e3..dfc1277a71 100644 --- a/lib/timespec.h +++ b/lib/timespec.h @@ -74,7 +74,7 @@ make_timespec (time_t s, long int ns) 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 @@ timespec_cmp (struct timespec a, struct timespec b) /* 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;