From 44827b6764da07e30eb6f7c97051d69956797fcb Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Sun, 20 Jan 2019 10:36:41 +0000 Subject: deprecation: add `used` attribute Recent GCC enables `-Wunused-const-variables`, which makes output quite noisy. Disable unused warnings for our deprecated variables. --- include/git2/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/git2/common.h b/include/git2/common.h index 8d3d3c111..70c02a48c 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -59,6 +59,7 @@ typedef size_t size_t; #if defined(__GNUC__) # define GIT_DEPRECATED(func) \ __attribute__((deprecated)) \ + __attribute__((used)) \ func #elif defined(_MSC_VER) # define GIT_DEPRECATED(func) __declspec(deprecated) func -- cgit v1.2.1 From 1b2af79e85705da5bce8e737bce9d0890d489853 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Sun, 20 Jan 2019 10:49:23 +0000 Subject: deprecation: use the enum type in declaration The C standard does not specify whether an enum is a signed or unsigned type. Obviously, any enum that includes negative values _must_ be signed, but if all values are positive then the compiler is free to choose signed or unsigned. Thus, by changing the type signatures to `git_object_t` and declaring the old `GIT_OBJ_` values as a signed or unsigned int, we risk a mismatch between what the compiler has chosen for a `git_object_t`'s type and our type declaration. Thus, we declare the deprecated values as the enum instead of guessing. --- include/git2/refs.h | 16 ++++++++-------- include/git2/types.h | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/git2/refs.h b/include/git2/refs.h index 84d99382b..c11947b4a 100644 --- a/include/git2/refs.h +++ b/include/git2/refs.h @@ -762,18 +762,18 @@ GIT_EXTERN(const char *) git_reference_shorthand(const git_reference *ref); #define git_ref_t git_reference_t #define git_reference_normalize_t git_reference_format_t -GIT_DEPRECATED(static const unsigned int) GIT_REF_INVALID = GIT_REFERENCE_INVALID; -GIT_DEPRECATED(static const unsigned int) GIT_REF_OID = GIT_REFERENCE_DIRECT; -GIT_DEPRECATED(static const unsigned int) GIT_REF_SYMBOLIC = GIT_REFERENCE_SYMBOLIC; -GIT_DEPRECATED(static const unsigned int) GIT_REF_LISTALL = GIT_REFERENCE_ALL; +GIT_DEPRECATED(static const git_ref_t) GIT_REF_INVALID = GIT_REFERENCE_INVALID; +GIT_DEPRECATED(static const git_ref_t) GIT_REF_OID = GIT_REFERENCE_DIRECT; +GIT_DEPRECATED(static const git_ref_t) GIT_REF_SYMBOLIC = GIT_REFERENCE_SYMBOLIC; +GIT_DEPRECATED(static const git_ref_t) GIT_REF_LISTALL = GIT_REFERENCE_ALL; -GIT_DEPRECATED(static const unsigned int) GIT_REF_FORMAT_NORMAL = +GIT_DEPRECATED(static const git_reference_normalize_t) GIT_REF_FORMAT_NORMAL = GIT_REFERENCE_FORMAT_NORMAL; -GIT_DEPRECATED(static const unsigned int) GIT_REF_FORMAT_ALLOW_ONELEVEL = +GIT_DEPRECATED(static const git_reference_normalize_t) GIT_REF_FORMAT_ALLOW_ONELEVEL = GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL; -GIT_DEPRECATED(static const unsigned int) GIT_REF_FORMAT_REFSPEC_PATTERN = +GIT_DEPRECATED(static const git_reference_normalize_t) GIT_REF_FORMAT_REFSPEC_PATTERN = GIT_REFERENCE_FORMAT_REFSPEC_PATTERN; -GIT_DEPRECATED(static const unsigned int) GIT_REF_FORMAT_REFSPEC_SHORTHAND = +GIT_DEPRECATED(static const git_reference_normalize_t) GIT_REF_FORMAT_REFSPEC_SHORTHAND = GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND; /**@}*/ diff --git a/include/git2/types.h b/include/git2/types.h index fdecc3ab6..386958d7b 100644 --- a/include/git2/types.h +++ b/include/git2/types.h @@ -450,19 +450,19 @@ typedef struct git_mailmap git_mailmap; /**@{*/ -GIT_DEPRECATED(static const int) GIT_OBJ_ANY = GIT_OBJECT_ANY; -GIT_DEPRECATED(static const int) GIT_OBJ_BAD = GIT_OBJECT_INVALID; -GIT_DEPRECATED(static const int) GIT_OBJ__EXT1 = 0; -GIT_DEPRECATED(static const int) GIT_OBJ_COMMIT = GIT_OBJECT_COMMIT; -GIT_DEPRECATED(static const int) GIT_OBJ_TREE = GIT_OBJECT_TREE; -GIT_DEPRECATED(static const int) GIT_OBJ_BLOB = GIT_OBJECT_BLOB; -GIT_DEPRECATED(static const int) GIT_OBJ_TAG = GIT_OBJECT_TAG; -GIT_DEPRECATED(static const int) GIT_OBJ__EXT2 = 5; -GIT_DEPRECATED(static const int) GIT_OBJ_OFS_DELTA = GIT_OBJECT_OFS_DELTA; -GIT_DEPRECATED(static const int) GIT_OBJ_REF_DELTA = GIT_OBJECT_REF_DELTA; - #define git_otype git_object_t +GIT_DEPRECATED(static const git_otype) GIT_OBJ_ANY = GIT_OBJECT_ANY; +GIT_DEPRECATED(static const git_otype) GIT_OBJ_BAD = GIT_OBJECT_INVALID; +GIT_DEPRECATED(static const git_otype) GIT_OBJ__EXT1 = 0; +GIT_DEPRECATED(static const git_otype) GIT_OBJ_COMMIT = GIT_OBJECT_COMMIT; +GIT_DEPRECATED(static const git_otype) GIT_OBJ_TREE = GIT_OBJECT_TREE; +GIT_DEPRECATED(static const git_otype) GIT_OBJ_BLOB = GIT_OBJECT_BLOB; +GIT_DEPRECATED(static const git_otype) GIT_OBJ_TAG = GIT_OBJECT_TAG; +GIT_DEPRECATED(static const git_otype) GIT_OBJ__EXT2 = 5; +GIT_DEPRECATED(static const git_otype) GIT_OBJ_OFS_DELTA = GIT_OBJECT_OFS_DELTA; +GIT_DEPRECATED(static const git_otype) GIT_OBJ_REF_DELTA = GIT_OBJECT_REF_DELTA; + /**@}*/ /** @} */ -- cgit v1.2.1