Skip to content

Commit

Permalink
Fixed strerror warnings for all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
kala13x committed Jan 29, 2025
1 parent 5ad4270 commit 65cf864
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions example/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ int main()
#ifdef _WIN32
strerror_s(sError, sizeof(sError), errno);
#else
char *pError = strerror_r(errno, sError, sizeof(sError));
(void)pError;
strerror_r(errno, sError, sizeof(sError));
#endif

/* Error message with errno string (in this case must be 'Success')*/
Expand Down
9 changes: 4 additions & 5 deletions src/slog.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,16 @@ static uint8_t slog_open_file(slog_file_t *pFile, const slog_config_t *pCfg, con

if (pFile->pHandle == NULL)
{
char sError[SLOG_INFO_MAX];

#ifdef _WIN32
char sError[SLOG_INFO_MAX];
strerror_s(sError, sizeof(sError), errno);
char *pError = sError;
#else
char *pError = strerror_r(errno, sError, sizeof(sError));
(void)pError;
char *pError = strerror(errno);
#endif

printf("<%s:%d> %s: [ERROR] Failed to open file: %s (%s)\n",
__FILE__, __LINE__, __func__, pFile->sFilePath, sError);
__FILE__, __LINE__, __func__, pFile->sFilePath, pError);

return 0;
}
Expand Down

0 comments on commit 65cf864

Please sign in to comment.