Skip to content

Commit

Permalink
[clang,tidy] fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
akallabeth committed Jan 15, 2025
1 parent 87e6cec commit ea2022b
Show file tree
Hide file tree
Showing 42 changed files with 145 additions and 118 deletions.
1 change: 1 addition & 0 deletions channels/sshagent/client/sshagent_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ static UINT sshagent_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMa
sshagent->listener_callback->iface.OnNewChannelConnection = sshagent_on_new_channel_connection;
sshagent->listener_callback->plugin = pPlugin;
sshagent->listener_callback->channel_mgr = pChannelMgr;
// NOLINTNEXTLINE(concurrency-mt-unsafe)
sshagent->listener_callback->agent_uds_path = getenv("SSH_AUTH_SOCK");

if (sshagent->listener_callback->agent_uds_path == NULL)
Expand Down
1 change: 1 addition & 0 deletions client/Wayland/wlfreerdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ static int wlfreerdp_run(freerdp* instance)

static BOOL wlf_client_global_init(void)
{
// NOLINTNEXTLINE(concurrency-mt-unsafe)
(void)setlocale(LC_ALL, "");

if (freerdp_handle_signals() != 0)
Expand Down
1 change: 1 addition & 0 deletions client/X11/xf_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1814,6 +1814,7 @@ static void xf_PanningChangeEventHandler(void* context, const PanningChangeEvent

static BOOL xfreerdp_client_global_init(void)
{
// NOLINTNEXTLINE(concurrency-mt-unsafe)
(void)setlocale(LC_ALL, "");

if (freerdp_handle_signals() != 0)
Expand Down
1 change: 1 addition & 0 deletions client/X11/xf_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ void xf_keyboard_send_key(xfContext* xfc, BOOL down, BOOL repeat, const XKeyEven
else
{
char str[3 * ARRAYSIZE(buffer)] = { 0 };
// NOLINTNEXTLINE(concurrency-mt-unsafe)
const size_t rc = wcstombs(str, buffer, ARRAYSIZE(buffer));

WCHAR wbuffer[ARRAYSIZE(buffer)] = { 0 };
Expand Down
1 change: 1 addition & 0 deletions client/X11/xf_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ int LogDynAndXGetWindowProperty_ex(wLog* log, const char* file, const char* fkt,

BOOL IsGnome(void)
{
// NOLINTNEXTLINE(concurrency-mt-unsafe)
char* env = getenv("DESKTOP_SESSION");
return (env != NULL && strcmp(env, "gnome") == 0);
}
Expand Down
1 change: 1 addition & 0 deletions libfreerdp/codec/test/TestFreeRDPCodecProgressive.c
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ static WINPR_NORETURN(void usage(const char* name))
{
FILE* fp = stdout;
(void)fprintf(fp, "%s <directory> <width> <height>\n", name);
// NOLINTNEXTLINE(concurrency-mt-unsafe)
exit(-1);
}

Expand Down
3 changes: 1 addition & 2 deletions libfreerdp/core/capabilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -4540,8 +4540,7 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s, UINT16 pduSource, UINT16 le
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
return FALSE;

UINT32 SessionId = 0;
Stream_Read_UINT32(s, SessionId); /* SessionId */
const UINT32 SessionId = Stream_Get_UINT32(s); /* SessionId */

{
rdp_secondary_update_internal* secondary = secondary_update_cast(rdp->update->secondary);
Expand Down
4 changes: 1 addition & 3 deletions libfreerdp/core/rdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,6 @@ static BOOL rdp_recv_server_shutdown_denied_pdu(rdpRdp* rdp, wStream* s)

static BOOL rdp_recv_server_set_keyboard_indicators_pdu(rdpRdp* rdp, wStream* s)
{
UINT16 ledFlags = 0;

WINPR_ASSERT(rdp);
WINPR_ASSERT(s);

Expand All @@ -993,7 +991,7 @@ static BOOL rdp_recv_server_set_keyboard_indicators_pdu(rdpRdp* rdp, wStream* s)
return FALSE;

const uint16_t unitId = Stream_Get_UINT16(s); /* unitId (2 bytes) */
Stream_Read_UINT16(s, ledFlags); /* ledFlags (2 bytes) */
const UINT16 ledFlags = Stream_Get_UINT16(s); /* ledFlags (2 bytes) */
return IFCALLRESULT(TRUE, context->update->SetKeyboardIndicators, context, ledFlags);
}

Expand Down
12 changes: 6 additions & 6 deletions libfreerdp/core/timezone.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ static char* systemtime2str(const SYSTEMTIME* t, char* buffer, size_t len)
const SYSTEMTIME empty = { 0 };

if (memcmp(t, &empty, sizeof(SYSTEMTIME)) == 0)
_snprintf(buffer, len, "{ not set }");
(void)_snprintf(buffer, len, "{ not set }");
else
{
_snprintf(buffer, len,
"{ %" PRIu16 "-%" PRIu16 "-%" PRIu16 " [%s] %" PRIu16 ":%" PRIu16 ":%" PRIu16
".%" PRIu16 "}",
t->wYear, t->wMonth, t->wDay, weekday2str(t->wDayOfWeek), t->wHour, t->wMinute,
t->wSecond, t->wMilliseconds);
(void)_snprintf(buffer, len,
"{ %" PRIu16 "-%" PRIu16 "-%" PRIu16 " [%s] %" PRIu16 ":%" PRIu16
":%" PRIu16 ".%" PRIu16 "}",
t->wYear, t->wMonth, t->wDay, weekday2str(t->wDayOfWeek), t->wHour,
t->wMinute, t->wSecond, t->wMilliseconds);
}
return buffer;
}
Expand Down
8 changes: 2 additions & 6 deletions libfreerdp/core/update.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,10 @@ static BOOL update_write_bitmap_data(rdpUpdate* update_pub, wStream* s, BITMAP_D
WINPR_ASSERTING_INT_CAST(
uint16_t, bitmapData->cbUncompressedSize)); /* cbUncompressedSize (2 bytes) */
}

Stream_Write(s, bitmapData->bitmapDataStream, bitmapData->bitmapLength);
}
else
{
Stream_Write(s, bitmapData->bitmapDataStream, bitmapData->bitmapLength);
}

Stream_Write(s, bitmapData->bitmapDataStream, bitmapData->bitmapLength);

return TRUE;
}

Expand Down
1 change: 1 addition & 0 deletions libfreerdp/utils/passphrase.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ static const char* freerdp_passphrase_read_askpass(const char* prompt, char* buf
const char* freerdp_passphrase_read(rdpContext* context, const char* prompt, char* buf,
size_t bufsiz, int from_stdin)
{
// NOLINTNEXTLINE(concurrency-mt-unsafe)
const char* askpass_env = getenv("FREERDP_ASKPASS");

if (askpass_env)
Expand Down
5 changes: 5 additions & 0 deletions libfreerdp/utils/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ static void term_handler(int signum)
if (!recursive)
{
recursive = TRUE;
// NOLINTNEXTLINE(concurrency-mt-unsafe)
WLog_ERR(TAG, "Caught signal '%s' [%d]", strsignal(signum), signum);
}

Expand All @@ -107,7 +108,10 @@ static void term_handler(int signum)
const cleanup_handler_t empty = { 0 };
cleanup_handler_t* cur = &cleanup_handlers[x];
if (cur->handler)
{
// NOLINTNEXTLINE(concurrency-mt-unsafe)
cur->handler(signum, strsignal(signum), cur->context);
}
*cur = empty;
}
cleanup_handler_count = 0;
Expand All @@ -123,6 +127,7 @@ static void fatal_handler(int signum)
if (!recursive)
{
recursive = TRUE;
// NOLINTNEXTLINE(concurrency-mt-unsafe)
WLog_ERR(TAG, "Caught signal '%s' [%d]", strsignal(signum), signum);

winpr_log_backtrace(TAG, WLOG_ERROR, 20);
Expand Down
1 change: 1 addition & 0 deletions server/proxy/cli/freerdp_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static const char* strsignal(int signum)
// NOLINTBEGIN(bugprone-signal-handler,cert-msc54-cpp,cert-sig30-c)
static void cleanup_handler(int signum)
{
// NOLINTNEXTLINE(concurrency-mt-unsafe)
WLog_INFO(TAG, "caught signal %s [%d], starting cleanup...", strsignal(signum), signum);

WLog_INFO(TAG, "stopping all connections.");
Expand Down
8 changes: 8 additions & 0 deletions server/shadow/X11/x11_shadow.c
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,12 @@ static int x11_shadow_subsystem_base_init(x11ShadowSubsystem* subsystem)
if (subsystem->display)
return 1; /* initialize once */

// NOLINTNEXTLINE(concurrency-mt-unsafe)
if (!getenv("DISPLAY"))
{
// NOLINTNEXTLINE(concurrency-mt-unsafe)
setenv("DISPLAY", ":0", 1);
}

if (!XInitThreads())
return -1;
Expand Down Expand Up @@ -1196,8 +1200,12 @@ UINT32 x11_shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors)
int displayHeight = 0;
int numMonitors = 0;

// NOLINTNEXTLINE(concurrency-mt-unsafe)
if (!getenv("DISPLAY"))
{
// NOLINTNEXTLINE(concurrency-mt-unsafe)
setenv("DISPLAY", ":0", 1);
}

display = XOpenDisplay(NULL);

Expand Down
4 changes: 2 additions & 2 deletions uwac/libuwac/uwac-os.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ int uwac_create_anonymous_file(off_t size)
static const char template[] = "/weston-shared-XXXXXX";
size_t length = 0;
char* name = NULL;
const char* path = NULL;
int fd = 0;
int ret = 0;
path = getenv("XDG_RUNTIME_DIR");
// NOLINTNEXTLINE(concurrency-mt-unsafe)
const char* path = getenv("XDG_RUNTIME_DIR");

if (!path)
{
Expand Down
1 change: 1 addition & 0 deletions uwac/libuwac/uwac-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static void* fail_on_null(void* p)
if (p == NULL)
{
(void)fprintf(stderr, "out of memory\n");
// NOLINTNEXTLINE(concurrency-mt-unsafe)
exit(EXIT_FAILURE);
}

Expand Down
1 change: 1 addition & 0 deletions uwac/libuwac/uwac-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ UwacWindow* UwacCreateWindowShm(UwacDisplay* display, uint32_t width, uint32_t h

#if BUILD_IVI
uint32_t ivi_surface_id = 1;
// NOLINTNEXTLINE(concurrency-mt-unsafe)
char* env = getenv("IVI_SURFACE_ID");
if (env)
{
Expand Down
4 changes: 2 additions & 2 deletions winpr/include/winpr/asn1.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ extern "C"
WINPR_API size_t WinPrAsn1EncContextualOID(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId,
const WinPrAsn1_OID* oid);
WINPR_API size_t WinPrAsn1EncOctetString(WinPrAsn1Encoder* enc,
const WinPrAsn1_OctetString* oid);
const WinPrAsn1_OctetString* octetstring);
WINPR_API size_t WinPrAsn1EncContextualOctetString(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId,
const WinPrAsn1_OctetString* oid);
const WinPrAsn1_OctetString* octetstring);
WINPR_API size_t WinPrAsn1EncIA5String(WinPrAsn1Encoder* enc, WinPrAsn1_IA5STRING ia5);
WINPR_API size_t WinPrAsn1EncGeneralString(WinPrAsn1Encoder* enc, WinPrAsn1_STRING str);
WINPR_API size_t WinPrAsn1EncContextualIA5String(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId,
Expand Down
4 changes: 2 additions & 2 deletions winpr/include/winpr/custom-crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extern "C"
WINPR_API BOOL winpr_HMAC_Init(WINPR_HMAC_CTX* ctx, WINPR_MD_TYPE md, const void* key,
size_t keylen);
WINPR_API BOOL winpr_HMAC_Update(WINPR_HMAC_CTX* ctx, const void* input, size_t ilen);
WINPR_API BOOL winpr_HMAC_Final(WINPR_HMAC_CTX* ctx, void* output, size_t ilen);
WINPR_API BOOL winpr_HMAC_Final(WINPR_HMAC_CTX* ctx, void* output, size_t olen);

WINPR_API BOOL winpr_HMAC(WINPR_MD_TYPE md, const void* key, size_t keylen, const void* input,
size_t ilen, void* output, size_t olen);
Expand All @@ -111,7 +111,7 @@ extern "C"
WINPR_API BOOL winpr_Digest_Init_Allow_FIPS(WINPR_DIGEST_CTX* ctx, WINPR_MD_TYPE md);
WINPR_API BOOL winpr_Digest_Init(WINPR_DIGEST_CTX* ctx, WINPR_MD_TYPE md);
WINPR_API BOOL winpr_Digest_Update(WINPR_DIGEST_CTX* ctx, const void* input, size_t ilen);
WINPR_API BOOL winpr_Digest_Final(WINPR_DIGEST_CTX* ctx, void* output, size_t ilen);
WINPR_API BOOL winpr_Digest_Final(WINPR_DIGEST_CTX* ctx, void* output, size_t olen);

WINPR_API BOOL winpr_Digest_Allow_FIPS(WINPR_MD_TYPE md, const void* input, size_t ilen,
void* output, size_t olen);
Expand Down
6 changes: 3 additions & 3 deletions winpr/include/winpr/print.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ extern "C"
{
#endif

WINPR_API void winpr_HexDump(const char* tag, UINT32 lvl, const void* data, size_t length);
WINPR_API void winpr_HexLogDump(wLog* log, UINT32 lvl, const void* data, size_t length);
WINPR_API void winpr_CArrayDump(const char* tag, UINT32 lvl, const void* data, size_t length,
WINPR_API void winpr_HexDump(const char* tag, UINT32 level, const void* data, size_t length);
WINPR_API void winpr_HexLogDump(wLog* log, UINT32 level, const void* data, size_t length);
WINPR_API void winpr_CArrayDump(const char* tag, UINT32 level, const void* data, size_t length,
size_t width);

WINPR_API char* winpr_BinToHexString(const BYTE* data, size_t length, BOOL space);
Expand Down
14 changes: 8 additions & 6 deletions winpr/include/winpr/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,12 @@ extern "C"
* The function does string conversions of any '\0' terminated input string
*
* \param wstr A '\0' terminated WCHAR string, may be NULL
* \param pSize Ignored if NULL, otherwise receives the length of the result string in
* \param pUtfCharLength Ignored if NULL, otherwise receives the length of the result string in
* characters (strlen)
*
* \return An allocated zero terminated UTF-8 string or NULL in case of failure.
*/
WINPR_API char* ConvertWCharToUtf8Alloc(const WCHAR* wstr, size_t* pSize);
WINPR_API char* ConvertWCharToUtf8Alloc(const WCHAR* wstr, size_t* pUtfCharLength);

/** \brief Converts form UTF-16 to UTF-8, returns an allocated string
*
Expand All @@ -332,12 +332,13 @@ extern "C"
*
* \param wstr A WCHAR string of \b wlen length
* \param wlen The (buffer) length in characters of \b wstr
* \param pSize Ignored if NULL, otherwise receives the length of the result string in
* \param pUtfCharLength Ignored if NULL, otherwise receives the length of the result string in
* characters (strlen)
*
* \return An allocated zero terminated UTF-8 string or NULL in case of failure.
*/
WINPR_API char* ConvertWCharNToUtf8Alloc(const WCHAR* wstr, size_t wlen, size_t* pSize);
WINPR_API char* ConvertWCharNToUtf8Alloc(const WCHAR* wstr, size_t wlen,
size_t* pUtfCharLength);

/** \brief Converts multistring form UTF-16 to UTF-8, returns an allocated string
*
Expand All @@ -346,12 +347,13 @@ extern "C"
*
* \param wstr A WCHAR string of \b len character length
* \param wlen The (buffer) length in characters of \b str
* \param pSize Ignored if NULL, otherwise receives the length of the result string in
* \param pUtfCharLength Ignored if NULL, otherwise receives the length of the result string in
* characters (including any '\0' character)
*
* \return An allocated double zero terminated UTF-8 string or NULL in case of failure.
*/
WINPR_API char* ConvertMszWCharNToUtf8Alloc(const WCHAR* wstr, size_t wlen, size_t* pSize);
WINPR_API char* ConvertMszWCharNToUtf8Alloc(const WCHAR* wstr, size_t wlen,
size_t* pUtfCharLength);

/** \brief Converts form UTF-8 to UTF-16, returns an allocated string
*
Expand Down
2 changes: 1 addition & 1 deletion winpr/include/winpr/synch.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ extern "C"
#define OpenWaitableTimer OpenWaitableTimerA
#endif

WINPR_API int GetTimerFileDescriptor(HANDLE hEvent);
WINPR_API int GetTimerFileDescriptor(HANDLE hTimer);

/**
* Timer-Queue Timer
Expand Down
2 changes: 2 additions & 0 deletions winpr/libwinpr/comm/comm_serial_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,7 @@ static BOOL set_break_off(WINPR_COMM* pComm)
static BOOL set_xoff(WINPR_COMM* pComm)
{
WINPR_ASSERT(pComm);
// NOLINTNEXTLINE(concurrency-mt-unsafe)
if (tcflow(pComm->fd, TCIOFF) < 0)
{
char ebuffer[256] = { 0 };
Expand All @@ -1572,6 +1573,7 @@ static BOOL set_xoff(WINPR_COMM* pComm)
static BOOL set_xon(WINPR_COMM* pComm)
{
WINPR_ASSERT(pComm);
// NOLINTNEXTLINE(concurrency-mt-unsafe)
if (tcflow(pComm->fd, TCION) < 0)
{
char ebuffer[256] = { 0 };
Expand Down
6 changes: 3 additions & 3 deletions winpr/libwinpr/crt/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ WCHAR* _wcsstr(const WCHAR* str, const WCHAR* strSearch)

/* _wcschr -> wcschr */

WCHAR* _wcschr(const WCHAR* str, WCHAR value)
WCHAR* _wcschr(const WCHAR* str, WCHAR c)
{
union
{
Expand All @@ -370,10 +370,10 @@ WCHAR* _wcschr(const WCHAR* str, WCHAR value)
} cnv;
const WCHAR* p = str;

while (*p && (*p != value))
while (*p && (*p != c))
p++;

cnv.cc = (*p == value) ? p : NULL;
cnv.cc = (*p == c) ? p : NULL;
return cnv.c;
}

Expand Down
4 changes: 2 additions & 2 deletions winpr/libwinpr/crypto/cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ static int cipher_compare(const void* a, const void* b)
return *cipher > map->md ? 1 : -1;
}

const char* winpr_cipher_type_to_string(WINPR_CIPHER_TYPE cipher)
const char* winpr_cipher_type_to_string(WINPR_CIPHER_TYPE md)
{
WINPR_CIPHER_TYPE lc = cipher;
WINPR_CIPHER_TYPE lc = md;
const struct cipher_map* ret = bsearch(&lc, s_cipher_map, ARRAYSIZE(s_cipher_map),
sizeof(struct cipher_map), cipher_compare);
if (!ret)
Expand Down
4 changes: 2 additions & 2 deletions winpr/libwinpr/crypto/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,12 +672,12 @@ BOOL winpr_Digest_Final(WINPR_DIGEST_CTX* ctx, void* output, size_t olen)
return FALSE;
}

BOOL winpr_DigestSign_Init(WINPR_DIGEST_CTX* ctx, WINPR_MD_TYPE digest, void* key)
BOOL winpr_DigestSign_Init(WINPR_DIGEST_CTX* ctx, WINPR_MD_TYPE md, void* key)
{
WINPR_ASSERT(ctx);

#if defined(WITH_OPENSSL)
const EVP_MD* evp = winpr_openssl_get_evp_md(digest);
const EVP_MD* evp = winpr_openssl_get_evp_md(md);
if (!evp)
return FALSE;

Expand Down
Loading

0 comments on commit ea2022b

Please sign in to comment.