build: fix -Wunused-macros warnings, and related tidy-ups

- fix internal macro `AN_APPLE_OS` reused between sources without
  resetting it. It may potentially have left the system sha256
  function unused.
- fix to define `WOLFSSL_OPTIONS_IGNORE_SYS` so that it always applies
  to wolfSSL headers, also during feature detection.
- md4, md5, sha256: simplify fallback logic.
- delete 20+ unused macros.
- scope or move macros to avoid `-Wunused-macros` warnings.
- examples: delete unused code.

The warning detects macros defined but not used within the same C
source. It does not warn for macros defined in headers. It also works
with unity builds, but to a lesser extent.

Closes #20593
This commit is contained in:
Viktor Szakats 2026-02-13 17:05:36 +01:00
parent 633ec719d5
commit 5fa5cb3825
No known key found for this signature in database
28 changed files with 105 additions and 161 deletions

View file

@ -47,8 +47,6 @@
#ifdef _WIN32
#include <windows.h>
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define unlink _unlink
#else
#include <strings.h>

View file

@ -108,9 +108,6 @@ static const char *MthStr[] = {
};
#endif
#define HTTP_COMMAND_HEAD 0
#define HTTP_COMMAND_GET 1
static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream)
{
fwrite(ptr, size, nmemb, stream);
@ -185,24 +182,15 @@ static void SyncTime_CURL_Init(CURL *curl, const char *proxy_port,
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, SyncTime_CURL_WriteHeader);
}
static CURLcode SyncTime_CURL_Fetch(CURL *curl, const char *URL_Str,
const char *OutFileName, int HttpGetBody)
static CURLcode SyncTime_CURL_FetchHead(CURL *curl, const char *URL_Str)
{
FILE *outfile;
CURLcode result;
outfile = NULL;
if(HttpGetBody == HTTP_COMMAND_HEAD)
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
else {
outfile = fopen(OutFileName, "wb");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
}
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
curl_easy_setopt(curl, CURLOPT_URL, URL_Str);
result = curl_easy_perform(curl);
if(outfile)
fclose(outfile);
return result; /* CURLE_OK */
}
@ -320,7 +308,7 @@ int main(int argc, const char *argv[])
fprintf(stderr, "Before HTTP. Date: %s%s\n\n", timeBuf, tzoneBuf);
/* HTTP HEAD command to the Webserver */
SyncTime_CURL_Fetch(curl, conf.timeserver, "index.htm", HTTP_COMMAND_HEAD);
SyncTime_CURL_FetchHead(curl, conf.timeserver);
#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP)
GetLocalTime(&LOCALTime);