Loading changes/ticket26527 0 → 100644 +3 −0 Original line number Diff line number Diff line o Code simplification and refactoring: - Remove ATTR_NONNULL macro from codebase. Resolves ticket 26527. src/lib/cc/compat_compiler.h +0 −11 Original line number Diff line number Diff line Loading @@ -125,16 +125,6 @@ #define ATTR_MALLOC __attribute__((malloc)) #define ATTR_NORETURN __attribute__((noreturn)) #define ATTR_WUR __attribute__((warn_unused_result)) /* Alas, nonnull is not at present a good idea for us. We'd like to get * warnings when we pass NULL where we shouldn't (which nonnull does, albeit * spottily), but we don't want to tell the compiler to make optimizations * with the assumption that the argument can't be NULL (since this would make * many of our checks go away, and make our code less robust against * programming errors). Unfortunately, nonnull currently does both of these * things, and there's no good way to split them up. * * #define ATTR_NONNULL(x) __attribute__((nonnull x)) */ #define ATTR_NONNULL(x) #define ATTR_UNUSED __attribute__ ((unused)) /** Macro: Evaluates to <b>exp</b> and hints the compiler that the value Loading @@ -158,7 +148,6 @@ #define ATTR_CONST #define ATTR_MALLOC #define ATTR_NORETURN #define ATTR_NONNULL(x) #define ATTR_UNUSED #define ATTR_WUR #define PREDICT_LIKELY(exp) (exp) Loading src/lib/fs/mmap.h +2 −2 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ typedef struct tor_mmap_t { } tor_mmap_t; tor_mmap_t *tor_mmap_file(const char *filename) ATTR_NONNULL((1)); int tor_munmap_file(tor_mmap_t *handle) ATTR_NONNULL((1)); tor_mmap_t *tor_mmap_file(const char *filename); int tor_munmap_file(tor_mmap_t *handle); #endif src/lib/malloc/util_malloc.h +4 −4 Original line number Diff line number Diff line Loading @@ -21,13 +21,13 @@ void *tor_malloc_zero_(size_t size) ATTR_MALLOC; void *tor_calloc_(size_t nmemb, size_t size) ATTR_MALLOC; void *tor_realloc_(void *ptr, size_t size); void *tor_reallocarray_(void *ptr, size_t size1, size_t size2); char *tor_strdup_(const char *s) ATTR_MALLOC ATTR_NONNULL((1)); char *tor_strdup_(const char *s) ATTR_MALLOC; char *tor_strndup_(const char *s, size_t n) ATTR_MALLOC ATTR_NONNULL((1)); ATTR_MALLOC; void *tor_memdup_(const void *mem, size_t len) ATTR_MALLOC ATTR_NONNULL((1)); ATTR_MALLOC; void *tor_memdup_nulterm_(const void *mem, size_t len) ATTR_MALLOC ATTR_NONNULL((1)); ATTR_MALLOC; void tor_free_(void *mem); /** Release memory allocated by tor_malloc, tor_realloc, tor_strdup, Loading src/lib/string/compat_string.h +2 −2 Original line number Diff line number Diff line Loading @@ -41,10 +41,10 @@ static inline int strcasecmp(const char *a, const char *b, size_t n) { #endif /* defined __APPLE__ */ #ifndef HAVE_STRLCAT size_t strlcat(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2)); size_t strlcat(char *dst, const char *src, size_t siz); #endif #ifndef HAVE_STRLCPY size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2)); size_t strlcpy(char *dst, const char *src, size_t siz); #endif char *tor_strtok_r_impl(char *str, const char *sep, char **lasts); Loading Loading
changes/ticket26527 0 → 100644 +3 −0 Original line number Diff line number Diff line o Code simplification and refactoring: - Remove ATTR_NONNULL macro from codebase. Resolves ticket 26527.
src/lib/cc/compat_compiler.h +0 −11 Original line number Diff line number Diff line Loading @@ -125,16 +125,6 @@ #define ATTR_MALLOC __attribute__((malloc)) #define ATTR_NORETURN __attribute__((noreturn)) #define ATTR_WUR __attribute__((warn_unused_result)) /* Alas, nonnull is not at present a good idea for us. We'd like to get * warnings when we pass NULL where we shouldn't (which nonnull does, albeit * spottily), but we don't want to tell the compiler to make optimizations * with the assumption that the argument can't be NULL (since this would make * many of our checks go away, and make our code less robust against * programming errors). Unfortunately, nonnull currently does both of these * things, and there's no good way to split them up. * * #define ATTR_NONNULL(x) __attribute__((nonnull x)) */ #define ATTR_NONNULL(x) #define ATTR_UNUSED __attribute__ ((unused)) /** Macro: Evaluates to <b>exp</b> and hints the compiler that the value Loading @@ -158,7 +148,6 @@ #define ATTR_CONST #define ATTR_MALLOC #define ATTR_NORETURN #define ATTR_NONNULL(x) #define ATTR_UNUSED #define ATTR_WUR #define PREDICT_LIKELY(exp) (exp) Loading
src/lib/fs/mmap.h +2 −2 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ typedef struct tor_mmap_t { } tor_mmap_t; tor_mmap_t *tor_mmap_file(const char *filename) ATTR_NONNULL((1)); int tor_munmap_file(tor_mmap_t *handle) ATTR_NONNULL((1)); tor_mmap_t *tor_mmap_file(const char *filename); int tor_munmap_file(tor_mmap_t *handle); #endif
src/lib/malloc/util_malloc.h +4 −4 Original line number Diff line number Diff line Loading @@ -21,13 +21,13 @@ void *tor_malloc_zero_(size_t size) ATTR_MALLOC; void *tor_calloc_(size_t nmemb, size_t size) ATTR_MALLOC; void *tor_realloc_(void *ptr, size_t size); void *tor_reallocarray_(void *ptr, size_t size1, size_t size2); char *tor_strdup_(const char *s) ATTR_MALLOC ATTR_NONNULL((1)); char *tor_strdup_(const char *s) ATTR_MALLOC; char *tor_strndup_(const char *s, size_t n) ATTR_MALLOC ATTR_NONNULL((1)); ATTR_MALLOC; void *tor_memdup_(const void *mem, size_t len) ATTR_MALLOC ATTR_NONNULL((1)); ATTR_MALLOC; void *tor_memdup_nulterm_(const void *mem, size_t len) ATTR_MALLOC ATTR_NONNULL((1)); ATTR_MALLOC; void tor_free_(void *mem); /** Release memory allocated by tor_malloc, tor_realloc, tor_strdup, Loading
src/lib/string/compat_string.h +2 −2 Original line number Diff line number Diff line Loading @@ -41,10 +41,10 @@ static inline int strcasecmp(const char *a, const char *b, size_t n) { #endif /* defined __APPLE__ */ #ifndef HAVE_STRLCAT size_t strlcat(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2)); size_t strlcat(char *dst, const char *src, size_t siz); #endif #ifndef HAVE_STRLCPY size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2)); size_t strlcpy(char *dst, const char *src, size_t siz); #endif char *tor_strtok_r_impl(char *str, const char *sep, char **lasts); Loading