Skip to content

Commit cc4f8bc

Browse files
authored
Merge pull request libgit2#6005 from boretrk/c11-warnings
C11 warnings
2 parents c8f4b56 + 40f3702 commit cc4f8bc

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ ELSE ()
233233
enable_warnings(unused-const-variable)
234234
enable_warnings(unused-function)
235235
enable_warnings(int-conversion)
236+
enable_warnings(c11-extensions)
236237

237238
# MinGW uses gcc, which expects POSIX formatting for printf, but
238239
# uses the Windows C library, which uses its own format specifiers.

src/hash.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ int git_hash_ctx_init(git_hash_ctx *ctx)
1616
{
1717
int error;
1818

19-
if ((error = git_hash_sha1_ctx_init(&ctx->sha1)) < 0)
19+
if ((error = git_hash_sha1_ctx_init(&ctx->ctx.sha1)) < 0)
2020
return error;
2121

2222
ctx->algo = GIT_HASH_ALGO_SHA1;
@@ -28,7 +28,7 @@ void git_hash_ctx_cleanup(git_hash_ctx *ctx)
2828
{
2929
switch (ctx->algo) {
3030
case GIT_HASH_ALGO_SHA1:
31-
git_hash_sha1_ctx_cleanup(&ctx->sha1);
31+
git_hash_sha1_ctx_cleanup(&ctx->ctx.sha1);
3232
return;
3333
default:
3434
/* unreachable */ ;
@@ -39,7 +39,7 @@ int git_hash_init(git_hash_ctx *ctx)
3939
{
4040
switch (ctx->algo) {
4141
case GIT_HASH_ALGO_SHA1:
42-
return git_hash_sha1_init(&ctx->sha1);
42+
return git_hash_sha1_init(&ctx->ctx.sha1);
4343
default:
4444
/* unreachable */ ;
4545
}
@@ -51,7 +51,7 @@ int git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
5151
{
5252
switch (ctx->algo) {
5353
case GIT_HASH_ALGO_SHA1:
54-
return git_hash_sha1_update(&ctx->sha1, data, len);
54+
return git_hash_sha1_update(&ctx->ctx.sha1, data, len);
5555
default:
5656
/* unreachable */ ;
5757
}
@@ -63,7 +63,7 @@ int git_hash_final(git_oid *out, git_hash_ctx *ctx)
6363
{
6464
switch (ctx->algo) {
6565
case GIT_HASH_ALGO_SHA1:
66-
return git_hash_sha1_final(out, &ctx->sha1);
66+
return git_hash_sha1_final(out, &ctx->ctx.sha1);
6767
default:
6868
/* unreachable */ ;
6969
}

src/hash.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef enum {
2727
typedef struct git_hash_ctx {
2828
union {
2929
git_hash_sha1_ctx sha1;
30-
};
30+
} ctx;
3131
git_hash_algo_t algo;
3232
} git_hash_ctx;
3333

0 commit comments

Comments
 (0)