aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common.h5
-rw-r--r--libar2.h9
-rw-r--r--libar2_erase.c1
-rw-r--r--libar2_type_to_string.c5
-rw-r--r--libar2_validate_params.c2
-rw-r--r--test.c46
6 files changed, 44 insertions, 24 deletions
diff --git a/common.h b/common.h
index ba49332..d918563 100644
--- a/common.h
+++ b/common.h
@@ -62,3 +62,8 @@
struct block {
uint_least64_t w[1024 / (64 / 8)];
};
+
+
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wc++98-compat"
+#endif
diff --git a/libar2.h b/libar2.h
index 862723f..2628217 100644
--- a/libar2.h
+++ b/libar2.h
@@ -5,6 +5,11 @@
#include <stddef.h>
#include <stdint.h>
+#if defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wpadded"
+#endif
+
/* for internal use { */
#ifndef LIBAR2_PUBLIC__
@@ -643,4 +648,8 @@ void libar2_erase(volatile void *mem, size_t size);
LIBAR2_PUBLIC__
int libar2_hash(void *hash, void *msg, size_t msglen, struct libar2_argon2_parameters *params, struct libar2_context *ctx);
+#if defined(__clang__)
+# pragma clang diagnostic pop
+#endif
+
#endif
diff --git a/libar2_erase.c b/libar2_erase.c
index 417842f..6760390 100644
--- a/libar2_erase.c
+++ b/libar2_erase.c
@@ -9,6 +9,7 @@
# if defined(__GNUC__)
__attribute__((visibility("hidden")))
# endif
+extern void *(*const volatile libar2_internal_explicit_memset__)(void *, int, size_t);
void *(*const volatile libar2_internal_explicit_memset__)(void *, int, size_t) = &memset;
#endif
diff --git a/libar2_type_to_string.c b/libar2_type_to_string.c
index 3092101..4866107 100644
--- a/libar2_type_to_string.c
+++ b/libar2_type_to_string.c
@@ -11,9 +11,14 @@ libar2_type_to_string(enum libar2_argon2_type type, enum libar2_casing casing)
{"ARGON2D", "ARGON2I", "ARGON2ID", NULL, "ARGON2DS"}
};
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wtautological-unsigned-enum-zero-compare"
+#endif
+
if (type < 0 || casing < 0 || type >= ELEMSOF(*strs) || casing >= ELEMSOF(strs) || !strs[casing][type]) {
errno = EINVAL;
return NULL;
}
+
return strs[casing][type];
}
diff --git a/libar2_validate_params.c b/libar2_validate_params.c
index 02d159a..f304985 100644
--- a/libar2_validate_params.c
+++ b/libar2_validate_params.c
@@ -11,7 +11,7 @@ libar2_validate_params(const struct libar2_argon2_parameters *params, const char
*errmsgp = ERRMESG;\
return ENUM;\
}
- LIBAR2_LIST_PARAMETER_ERRORS(LIBAR2_X__, params);
+ LIBAR2_LIST_PARAMETER_ERRORS(LIBAR2_X__, params)
#undef LIBAR2_X__
if (errmsgp)
diff --git a/test.c b/test.c
index 9aea93a..8172e16 100644
--- a/test.c
+++ b/test.c
@@ -158,40 +158,40 @@ check_libar2_type_to_string(void)
assert_streq(libar2_type_to_string(LIBAR2_ARGON2DS, LIBAR2_UPPER_CASE), "ARGON2DS");
assert(errno == 0);
- assert_streq(libar2_type_to_string(LIBAR2_ARGON2I, -1), NULL);
+ assert_streq(libar2_type_to_string(LIBAR2_ARGON2I, (enum libar2_casing)-1), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_type_to_string(LIBAR2_ARGON2I, 3), NULL);
+ assert_streq(libar2_type_to_string(LIBAR2_ARGON2I, (enum libar2_casing)3), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_type_to_string(3, LIBAR2_LOWER_CASE), NULL);
+ assert_streq(libar2_type_to_string((enum libar2_argon2_type)3, LIBAR2_LOWER_CASE), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_type_to_string(3, LIBAR2_TITLE_CASE), NULL);
+ assert_streq(libar2_type_to_string((enum libar2_argon2_type)3, LIBAR2_TITLE_CASE), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_type_to_string(3, LIBAR2_UPPER_CASE), NULL);
+ assert_streq(libar2_type_to_string((enum libar2_argon2_type)3, LIBAR2_UPPER_CASE), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_type_to_string(-1, LIBAR2_LOWER_CASE), NULL);
+ assert_streq(libar2_type_to_string((enum libar2_argon2_type)-1, LIBAR2_LOWER_CASE), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_type_to_string(-1, LIBAR2_TITLE_CASE), NULL);
+ assert_streq(libar2_type_to_string((enum libar2_argon2_type)-1, LIBAR2_TITLE_CASE), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_type_to_string(-1, LIBAR2_UPPER_CASE), NULL);
+ assert_streq(libar2_type_to_string((enum libar2_argon2_type)-1, LIBAR2_UPPER_CASE), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_type_to_string(5, LIBAR2_LOWER_CASE), NULL);
+ assert_streq(libar2_type_to_string((enum libar2_argon2_type)5, LIBAR2_LOWER_CASE), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_type_to_string(5, LIBAR2_TITLE_CASE), NULL);
+ assert_streq(libar2_type_to_string((enum libar2_argon2_type)5, LIBAR2_TITLE_CASE), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_type_to_string(5, LIBAR2_UPPER_CASE), NULL);
+ assert_streq(libar2_type_to_string((enum libar2_argon2_type)5, LIBAR2_UPPER_CASE), NULL);
assert(errno == EINVAL);
errno = 0;
}
@@ -295,15 +295,15 @@ check_libar2_version_to_string(void)
assert_streq(libar2_version_to_string(0x13), "13");
assert(errno == 0);
- assert_streq(libar2_version_to_string(0x11), NULL);
+ assert_streq(libar2_version_to_string((enum libar2_argon2_version)0x11), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_version_to_string(0x12), NULL);
+ assert_streq(libar2_version_to_string((enum libar2_argon2_version)0x12), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_version_to_string(0), NULL);
+ assert_streq(libar2_version_to_string((enum libar2_argon2_version)0), NULL);
assert(errno == EINVAL);
errno = 0;
}
@@ -326,15 +326,15 @@ check_libar2_version_to_string_proper(void)
assert_streq(libar2_version_to_string_proper(0x13), "1.3");
assert(errno == 0);
- assert_streq(libar2_version_to_string_proper(0x11), NULL);
+ assert_streq(libar2_version_to_string_proper((enum libar2_argon2_version)0x11), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_version_to_string_proper(0x12), NULL);
+ assert_streq(libar2_version_to_string_proper((enum libar2_argon2_version)0x12), NULL);
assert(errno == EINVAL);
errno = 0;
- assert_streq(libar2_version_to_string_proper(0), NULL);
+ assert_streq(libar2_version_to_string_proper((enum libar2_argon2_version)0), NULL);
assert(errno == EINVAL);
errno = 0;
}
@@ -624,7 +624,7 @@ check_libar2_validate_params(void)
assert(errno == 0);
params.lanes = 1;
- params.type = -1;
+ params.type = (enum libar2_argon2_type)-1;
assert(libar2_validate_params(&params, &errmsg) == LIBAR2_INVALID_TYPE);
assert_streq(errmsg, "type parameter is invalid");
assert(errno == 0);
@@ -633,7 +633,7 @@ check_libar2_validate_params(void)
assert(errno == 0);
params.type = 0;
- params.type = 3;
+ params.type = (enum libar2_argon2_type)3;
assert(libar2_validate_params(&params, &errmsg) == LIBAR2_INVALID_TYPE);
assert_streq(errmsg, "type parameter is invalid");
assert(errno == 0);
@@ -642,7 +642,7 @@ check_libar2_validate_params(void)
assert(errno == 0);
params.type = 0;
- params.type = 5;
+ params.type = (enum libar2_argon2_type)5;
assert(libar2_validate_params(&params, &errmsg) == LIBAR2_INVALID_TYPE);
assert_streq(errmsg, "type parameter is invalid");
assert(errno == 0);
@@ -651,14 +651,14 @@ check_libar2_validate_params(void)
assert(errno == 0);
params.type = 0;
- params.version = 0x11;
+ params.version = (enum libar2_argon2_version)0x11;
assert(libar2_validate_params(&params, &errmsg) == LIBAR2_INVALID_VERSION);
assert_streq(errmsg, "version parameter is invalid");
assert(errno == 0);
errmsg = NULL;
assert(libar2_validate_params(&params, NULL) == LIBAR2_INVALID_VERSION);
assert(errno == 0);
- params.type = 0x10;
+ params.version = 0x10;
}
@@ -691,7 +691,7 @@ static void
check_libar2_hash(void)
{
#define CHECK(PWD, HASH)\
- check_hash(MEM(PWD), HASH, &ctx_st, __LINE__);
+ check_hash(MEM(PWD), HASH, &ctx_st, __LINE__)
CHECK("\x00", "$argon2d$v=16$m=8,t=1,p=1$ICAgICAgICA$Eyx1BxGazSuPQoy7osaQuo20Dw9VI97dYUOgcC3cMgw");
CHECK("test", "$argon2i$v=19$m=4096,t=3,p=1$fn5/f35+f38$9tqKA4WMEsSAOEUwatjxvJLSqL1j0GQkgbsfnpresDw");