Skip to content

Commit 833e379

Browse files
committed
[acquire/tests/CMakeLists.txt] Ensure STRERRORLEN_IMPL is here on non Windows ; [acquire/acquire_*.h] Minor changes to be C89 compliant and resolve all such warnings on Linux
1 parent af4eabe commit 833e379

File tree

7 files changed

+21
-15
lines changed

7 files changed

+21
-15
lines changed

acquire/acquire_librhash.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ struct rhash_backend {
2121
unsigned int algorithm_id;
2222
};
2323

24+
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
25+
#else
26+
__attribute__((unused))
27+
#endif
2428
static int rhash_lib_initialized = 0;
2529

2630
extern LIBACQUIRE_EXPORT int

acquire/acquire_miniz.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <stdio.h>
77
#include <stdlib.h>
88

9-
#include <kubazip/zip/zip.h>
9+
#include <kubazip/zip.h>
1010

1111
#include "acquire_extract.h"
1212
#include "acquire_fileutils.h"

acquire/acquire_openssl.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,16 @@ int _openssl_verify_async_start(struct acquire_handle *handle,
138138
break;
139139
}
140140
#else
141-
const EVP_MD *md =
142-
(algorithm == LIBACQUIRE_SHA256) ? EVP_sha256() : EVP_sha512();
143-
be->ctx = EVP_MD_CTX_new();
144-
if (!be->ctx || (1 != EVP_DigestInit_ex(be->ctx, md, NULL))) {
145-
cleanup_openssl_backend(handle);
146-
acquire_handle_set_error(handle, ACQUIRE_ERROR_UNKNOWN,
147-
"EVP_DigestInit_ex failed");
148-
return -1;
141+
{
142+
const EVP_MD *md =
143+
(algorithm == LIBACQUIRE_SHA256) ? EVP_sha256() : EVP_sha512();
144+
be->ctx = EVP_MD_CTX_new();
145+
if (!be->ctx || (1 != EVP_DigestInit_ex(be->ctx, md, NULL))) {
146+
cleanup_openssl_backend(handle);
147+
acquire_handle_set_error(handle, ACQUIRE_ERROR_UNKNOWN,
148+
"EVP_DigestInit_ex failed");
149+
return -1;
150+
}
149151
}
150152
#endif
151153

acquire/acquire_string_extras.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ typedef int errno_t;
8686
#define strerror_s strerror_r
8787
#endif /* !strerror_s */
8888

89-
#define HAVE_STRERRORLEN_S 1
89+
/*#define HAVE_STRERRORLEN_S 1*/
9090
#endif /* defined(__linux__) || defined(linux) || defined(__linux) || \
9191
defined(ANY_BSD) */
9292

@@ -130,7 +130,7 @@ extern LIBACQUIRE_EXPORT char *strcasestr(const char *, const char *);
130130
#endif /* !defined(HAVE_STRCASESTR) || defined(STRCASESTR_IMPL) && \
131131
STRCASESTR_IMPL */
132132

133-
#if !defined(HAVE_STRERRORLEN_S) || \
133+
#if !defined(HAVE_STRERRORLEN_S) || HAVE_STRERRORLEN_S == 0 || \
134134
defined(STRERRORLEN_IMPL) && STRERRORLEN_IMPL
135135

136136
extern LIBACQUIRE_EXPORT size_t strerrorlen_s(errno_t);

acquire/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ if (MSVC)
188188
PROPERTIES COMPILE_DEFINITIONS "LIBACQUIRE_IMPLEMENTATION=1;STRCASESTR_IMPL=1;STRNCASECMP_IMPL=0;STRNSTR_IMPL=1;STRERRORLEN_IMPL=1")
189189
else ()
190190
set_source_files_properties("test_string_extras.c"
191-
PROPERTIES COMPILE_DEFINITIONS "LIBACQUIRE_IMPLEMENTATION=1")
191+
PROPERTIES COMPILE_DEFINITIONS "LIBACQUIRE_IMPLEMENTATION=1;STRERRORLEN_IMPL=1")
192192
endif ()
193193
#set_source_files_properties("test.c"
194194
# PROPERTIES COMPILE_DEFINITIONS "LIBACQUIRE_DOWNLOAD_DIR_IMPL=1")

acquire/tests/test_fileutils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ typedef size_t num_type;
2222
#define BOOL_FORMAT NUM_FORMAT
2323
#elif defined(__linux__) || defined(linux) || defined(__linux)
2424
#ifndef NUM_FORMAT
25-
#define NUM_FORMAT "d"
25+
#define NUM_FORMAT "ld"
2626
typedef int num_type;
2727
#endif /* !NUM_FORMAT */
28-
#define BOOL_FORMAT "d"
28+
#define BOOL_FORMAT "ld"
2929
#else
3030
#ifndef NUM_FORMAT
3131
#define NUM_FORMAT "d"

acquire/tests/test_string_extras.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ TEST test_strerrorlen_s_impl(void) {
7171
#else
7272
{
7373
const char *err_str = strerror(EDOM);
74-
ASSERT_EQ_FMT(strlen(err_str), len, "%zu");
74+
ASSERT_EQ_FMT(strlen(err_str), len, "%ld");
7575
}
7676
#endif
7777
PASS();

0 commit comments

Comments
 (0)