mirror of https://github.com/FreeRDP/FreeRDP
commit
43e471938b
|
@ -60,6 +60,7 @@ Checks: >
|
|||
-llvm-qualified-auto,
|
||||
-llvm-else-after-return,
|
||||
-readability-else-after-return,
|
||||
-readability-avoid-nested-conditional-operator,
|
||||
-modernize-use-trailing-return-type,
|
||||
-modernize-return-braced-init-list,
|
||||
-modernize-macro-to-enum,
|
||||
|
|
|
@ -1615,7 +1615,8 @@ static int udev_get_device_handle(URBDRC_PLUGIN* urbdrc, libusb_context* ctx, UD
|
|||
error = 0;
|
||||
WLog_Print(urbdrc->log, WLOG_DEBUG, " Port: %d", pdev->port_number);
|
||||
/* gen device path */
|
||||
(void)sprintf(pdev->path, "%" PRIu16 "-%d", bus_number, pdev->port_number);
|
||||
(void)_snprintf(pdev->path, sizeof(pdev->path), "%" PRIu16 "-%d", bus_number,
|
||||
pdev->port_number);
|
||||
|
||||
WLog_Print(urbdrc->log, WLOG_DEBUG, " DevPath: %s", pdev->path);
|
||||
}
|
||||
|
|
|
@ -1503,11 +1503,13 @@ BOOL vgids_init(vgidsContext* ctx, const char* cert, const char* privateKey, con
|
|||
goto init_failed;
|
||||
|
||||
/* create masterfile */
|
||||
// NOLINTNEXTLINE(clang-analyzer-unix.Malloc)
|
||||
masterEF = vgids_ef_new(ctx, VGIDS_EFID_MASTER);
|
||||
if (!masterEF)
|
||||
goto init_failed;
|
||||
|
||||
/* create cardid file with cardid DO */
|
||||
// NOLINTNEXTLINE(clang-analyzer-unix.Malloc)
|
||||
cardidEF = vgids_ef_new(ctx, VGIDS_EFID_CARDID);
|
||||
if (!cardidEF)
|
||||
goto init_failed;
|
||||
|
@ -1516,6 +1518,7 @@ BOOL vgids_init(vgidsContext* ctx, const char* cert, const char* privateKey, con
|
|||
goto init_failed;
|
||||
|
||||
/* create user common file */
|
||||
// NOLINTNEXTLINE(clang-analyzer-unix.Malloc)
|
||||
commonEF = vgids_ef_new(ctx, VGIDS_EFID_COMMON);
|
||||
if (!commonEF)
|
||||
goto init_failed;
|
||||
|
|
|
@ -71,23 +71,19 @@
|
|||
#endif // GOOGLE_PROFILER
|
||||
|
||||
extern float measure_delta_time(UINT64 t0, UINT64 t1);
|
||||
extern void measure_floatprint(float t, char* output);
|
||||
extern void measure_floatprint(float t, char* output, size_t len);
|
||||
|
||||
#define MEASURE_LOOP_START(_prefix_, _count_) \
|
||||
{ \
|
||||
UINT64 _start, _stop; \
|
||||
char* _prefix; \
|
||||
int _count = (_count_); \
|
||||
int _loop; \
|
||||
float _delta; \
|
||||
char _str1[32], _str2[32]; \
|
||||
_prefix = _strdup(_prefix_); \
|
||||
_str1[0] = '\0'; \
|
||||
_str2[0] = '\0'; \
|
||||
_start = winpr_GetTickCount64NS(); \
|
||||
PROFILER_START(_prefix); \
|
||||
_loop = (_count); \
|
||||
do \
|
||||
#define MEASURE_LOOP_START(_prefix_, _count_) \
|
||||
{ \
|
||||
int _count = (_count_); \
|
||||
int _loop; \
|
||||
char str1[32] = { 0 }; \
|
||||
char str2[32] = { 0 }; \
|
||||
char* _prefix = _strdup(_prefix_); \
|
||||
const UINT64 start = winpr_GetTickCount64NS(); \
|
||||
PROFILER_START(_prefix); \
|
||||
_loop = (_count); \
|
||||
do \
|
||||
{
|
||||
|
||||
#define MEASURE_LOOP_STOP \
|
||||
|
@ -95,33 +91,33 @@ extern void measure_floatprint(float t, char* output);
|
|||
while (--_loop) \
|
||||
;
|
||||
|
||||
#define MEASURE_GET_RESULTS(_result_) \
|
||||
PROFILER_STOP; \
|
||||
_stop = winpr_GetTickCount64NS(); \
|
||||
_delta = measure_delta_time(_start, _stop); \
|
||||
(_result_) = (float)_count / _delta; \
|
||||
free(_prefix); \
|
||||
#define MEASURE_GET_RESULTS(_result_) \
|
||||
PROFILER_STOP; \
|
||||
const UINT64 stop = winpr_GetTickCount64NS(); \
|
||||
const float delta = measure_delta_time(start, stop); \
|
||||
(_result_) = (float)_count / delta; \
|
||||
free(_prefix); \
|
||||
}
|
||||
|
||||
#define MEASURE_SHOW_RESULTS(_result_) \
|
||||
PROFILER_STOP; \
|
||||
_stop = winpr_GetTickCount64NS(); \
|
||||
_delta = measure_delta_time(_start, _stop); \
|
||||
(_result_) = (float)_count / _delta; \
|
||||
measure_floatprint((float)_count / _delta, _str1); \
|
||||
printf("%s: %9d iterations in %5.1f seconds = %s/s \n", _prefix, _count, _delta, _str1); \
|
||||
free(_prefix); \
|
||||
#define MEASURE_SHOW_RESULTS(_result_) \
|
||||
PROFILER_STOP; \
|
||||
const UINT64 stop = winpr_GetTickCount64NS(); \
|
||||
const float delta = measure_delta_time(start, stop); \
|
||||
(_result_) = (float)_count / delta; \
|
||||
measure_floatprint((float)_count / delta, str1); \
|
||||
printf("%s: %9d iterations in %5.1f seconds = %s/s \n", _prefix, _count, delta, str1); \
|
||||
free(_prefix); \
|
||||
}
|
||||
|
||||
#define MEASURE_SHOW_RESULTS_SCALED(_scale_, _label_) \
|
||||
PROFILER_STOP; \
|
||||
_stop = winpr_GetTickCount64NS(); \
|
||||
_delta = measure_delta_time(_start, _stop); \
|
||||
measure_floatprint((float)_count / _delta, _str1); \
|
||||
measure_floatprint((float)_count / _delta * (_scale_), _str2); \
|
||||
printf("%s: %9d iterations in %5.1f seconds = %s/s = %s%s \n", _prefix, _count, _delta, _str1, \
|
||||
_str2, _label_); \
|
||||
free(_prefix); \
|
||||
#define MEASURE_SHOW_RESULTS_SCALED(_scale_, _label_) \
|
||||
PROFILER_STOP; \
|
||||
const UINT64 stop = winpr_GetTickCount64NS(); \
|
||||
const float delta = measure_delta_time(start, stop); \
|
||||
measure_floatprint((float)_count / delta, str1); \
|
||||
measure_floatprint((float)_count / delta * (_scale_), str2); \
|
||||
printf("%s: %9d iterations in %5.1f seconds = %s/s = %s%s \n", _prefix, _count, delta, str1, \
|
||||
str2, _label_); \
|
||||
free(_prefix); \
|
||||
}
|
||||
|
||||
#define MEASURE_TIMED(_label_, _init_iter_, _test_time_, _result_, _call_) \
|
||||
|
|
|
@ -44,7 +44,7 @@ float measure_delta_time(UINT64 t0, UINT64 t1)
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
void measure_floatprint(float t, char* output)
|
||||
void measure_floatprint(float t, char* output, size_t len)
|
||||
{
|
||||
/* I don't want to link against -lm, so avoid log,exp,... */
|
||||
float f = 10.0;
|
||||
|
@ -57,19 +57,20 @@ void measure_floatprint(float t, char* output)
|
|||
i = ((int)(t / f + 0.5f)) * (int)f;
|
||||
|
||||
if (t < 0.0f)
|
||||
(void)sprintf(output, "%f", t);
|
||||
(void)_snprintf(output, len, "%f", t);
|
||||
else if (i == 0)
|
||||
(void)sprintf(output, "%d", (int)(t + 0.5f));
|
||||
(void)_snprintf(output, len, "%d", (int)(t + 0.5f));
|
||||
else if (t < 1e+3f)
|
||||
(void)sprintf(output, "%3d", i);
|
||||
(void)_snprintf(output, len, "%3d", i);
|
||||
else if (t < 1e+6f)
|
||||
(void)sprintf(output, "%3d,%03d", i / 1000, i % 1000);
|
||||
(void)_snprintf(output, len, "%3d,%03d", i / 1000, i % 1000);
|
||||
else if (t < 1e+9f)
|
||||
(void)sprintf(output, "%3d,%03d,000", i / 1000000, (i % 1000000) / 1000);
|
||||
(void)_snprintf(output, len, "%3d,%03d,000", i / 1000000, (i % 1000000) / 1000);
|
||||
else if (t < 1e+12f)
|
||||
(void)sprintf(output, "%3d,%03d,000,000", i / 1000000000, (i % 1000000000) / 1000000);
|
||||
(void)_snprintf(output, len, "%3d,%03d,000,000", i / 1000000000,
|
||||
(i % 1000000000) / 1000000);
|
||||
else
|
||||
(void)sprintf(output, "%f", t);
|
||||
(void)_snprintf(output, len, "%f", t);
|
||||
}
|
||||
|
||||
void prim_test_setup(BOOL performance)
|
||||
|
|
|
@ -132,7 +132,6 @@ static const char* freerdp_passphrase_read_tty(rdpContext* context, const char*
|
|||
{
|
||||
BOOL terminal_needs_reset = FALSE;
|
||||
char term_name[L_ctermid] = { 0 };
|
||||
int term_file = 0;
|
||||
|
||||
FILE* fout = NULL;
|
||||
|
||||
|
@ -144,15 +143,29 @@ static const char* freerdp_passphrase_read_tty(rdpContext* context, const char*
|
|||
|
||||
ctermid(term_name);
|
||||
int terminal_fildes = 0;
|
||||
if (from_stdin || strcmp(term_name, "") == 0 || (term_file = open(term_name, O_RDWR)) == -1)
|
||||
if (from_stdin || (strcmp(term_name, "") == 0))
|
||||
{
|
||||
fout = stdout;
|
||||
terminal_fildes = STDIN_FILENO;
|
||||
}
|
||||
else
|
||||
{
|
||||
fout = fdopen(term_file, "w");
|
||||
terminal_fildes = term_file;
|
||||
const int term_file = open(term_name, O_RDWR);
|
||||
if (term_file < 0)
|
||||
{
|
||||
fout = stdout;
|
||||
terminal_fildes = STDIN_FILENO;
|
||||
}
|
||||
else
|
||||
{
|
||||
fout = fdopen(term_file, "w");
|
||||
if (!fout)
|
||||
{
|
||||
close(term_file);
|
||||
return NULL;
|
||||
}
|
||||
terminal_fildes = term_file;
|
||||
}
|
||||
}
|
||||
|
||||
struct termios orig_flags = { 0 };
|
||||
|
|
|
@ -34,21 +34,24 @@
|
|||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#define WINPR_ASSERT(cond) \
|
||||
do \
|
||||
{ \
|
||||
WINPR_PRAGMA_DIAG_PUSH \
|
||||
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \
|
||||
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \
|
||||
WINPR_PRAGMA_DIAG_IGNORED_UNKNOWN_PRAGMAS \
|
||||
WINPR_DO_PRAGMA(coverity compliance deviate "NO_EFFECT:SUPPRESS" \
|
||||
"WINPR_ASSERT") \
|
||||
WINPR_DO_PRAGMA(coverity compliance deviate "CONSTANT_EXPRESSION_RESULT:SUPPRESS" \
|
||||
"WINPR_ASSERT") \
|
||||
\
|
||||
if (!(cond)) \
|
||||
winpr_int_assert(#cond, __FILE__, __func__, __LINE__); \
|
||||
WINPR_PRAGMA_DIAG_POP \
|
||||
#define WINPR_ASSERT(cond) \
|
||||
do \
|
||||
{ \
|
||||
WINPR_PRAGMA_DIAG_PUSH \
|
||||
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \
|
||||
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \
|
||||
WINPR_PRAGMA_DIAG_IGNORED_UNKNOWN_PRAGMAS \
|
||||
WINPR_DO_PRAGMA(coverity compliance block \x28 deviate "CONSTANT_EXPRESSION_RESULT" \
|
||||
"WINPR_ASSERT" \x29 \
|
||||
\x28 deviate "NO_EFFECT" \
|
||||
"WINPR_ASSERT" \x29) \
|
||||
\
|
||||
if (!(cond)) \
|
||||
winpr_int_assert(#cond, __FILE__, __func__, __LINE__); \
|
||||
\
|
||||
WINPR_DO_PRAGMA(coverity compliance end_block "CONSTANT_EXPRESSION_RESULT" \
|
||||
"NO_EFFECT") \
|
||||
WINPR_PRAGMA_DIAG_POP \
|
||||
} while (0)
|
||||
|
||||
static INLINE WINPR_NORETURN(void winpr_int_assert(const char* condstr, const char* file,
|
||||
|
@ -65,19 +68,22 @@ extern "C"
|
|||
#endif
|
||||
|
||||
#else
|
||||
#define WINPR_ASSERT(cond) \
|
||||
do \
|
||||
{ \
|
||||
WINPR_PRAGMA_DIAG_PUSH \
|
||||
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \
|
||||
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \
|
||||
WINPR_PRAGMA_DIAG_IGNORED_UNKNOWN_PRAGMAS \
|
||||
WINPR_DO_PRAGMA(coverity compliance deviate "NO_EFFECT:SUPPRESS" \
|
||||
"WINPR_ASSERT") \
|
||||
WINPR_DO_PRAGMA(coverity compliance deviate "CONSTANT_EXPRESSION_RESULT:SUPPRESS" \
|
||||
"WINPR_ASSERT") \
|
||||
assert(cond); \
|
||||
WINPR_PRAGMA_DIAG_POP \
|
||||
#define WINPR_ASSERT(cond) \
|
||||
do \
|
||||
{ \
|
||||
WINPR_PRAGMA_DIAG_PUSH \
|
||||
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \
|
||||
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \
|
||||
WINPR_PRAGMA_DIAG_IGNORED_UNKNOWN_PRAGMAS \
|
||||
WINPR_DO_PRAGMA(coverity compliance block \x28 deviate "CONSTANT_EXPRESSION_RESULT" \
|
||||
"WINPR_ASSERT" \x29 \
|
||||
\x28 deviate "NO_EFFECT" \
|
||||
"WINPR_ASSERT" \x29) \
|
||||
assert(cond); \
|
||||
\
|
||||
WINPR_DO_PRAGMA(coverity compliance end_block "CONSTANT_EXPRESSION_RESULT" \
|
||||
"NO_EFFECT") \
|
||||
WINPR_PRAGMA_DIAG_POP \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ int winpr_vasprintf(char** s, size_t* slen, WINPR_FORMAT_ARG const char* templ,
|
|||
return -1;
|
||||
|
||||
va_copy(ap, oap);
|
||||
const int plen = vsprintf(str, templ, ap);
|
||||
const int plen = vsnprintf(str, (size_t)length, templ, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (length != plen)
|
||||
|
|
|
@ -24,12 +24,15 @@
|
|||
#include <winpr/crt.h>
|
||||
#include <winpr/platform.h>
|
||||
#include <winpr/error.h>
|
||||
#include <winpr/file.h>
|
||||
#include <winpr/string.h>
|
||||
|
||||
#include <winpr/environment.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef WINPR_HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
@ -43,20 +46,35 @@
|
|||
|
||||
DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer)
|
||||
{
|
||||
char* cwd = NULL;
|
||||
size_t length = 0;
|
||||
char* cwd = NULL;
|
||||
char* ccwd = NULL;
|
||||
|
||||
cwd = getcwd(NULL, 0);
|
||||
do
|
||||
{
|
||||
length += MAX_PATH;
|
||||
char* tmp = realloc(cwd, length);
|
||||
if (!tmp)
|
||||
{
|
||||
free(cwd);
|
||||
return 0;
|
||||
}
|
||||
cwd = tmp;
|
||||
|
||||
if (!cwd)
|
||||
ccwd = getcwd(cwd, length);
|
||||
} while (!ccwd && (errno == ERANGE));
|
||||
|
||||
if (!ccwd)
|
||||
{
|
||||
free(cwd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
length = strlen(cwd);
|
||||
length = strnlen(cwd, length);
|
||||
|
||||
if ((nBufferLength == 0) && (lpBuffer == NULL))
|
||||
{
|
||||
free(cwd);
|
||||
|
||||
return (DWORD)length;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -44,6 +44,11 @@
|
|||
|
||||
struct format_option_recurse;
|
||||
|
||||
struct format_tid_arg
|
||||
{
|
||||
char tid[32];
|
||||
};
|
||||
|
||||
struct format_option
|
||||
{
|
||||
const char* fmt;
|
||||
|
@ -90,7 +95,9 @@ static void WLog_PrintMessagePrefix(wLog* log, wLogMessage* message,
|
|||
|
||||
static const char* get_tid(void* arg)
|
||||
{
|
||||
char* str = arg;
|
||||
struct format_tid_arg* targ = arg;
|
||||
WINPR_ASSERT(targ);
|
||||
|
||||
size_t tid = 0;
|
||||
#if defined __linux__ && !defined ANDROID
|
||||
/* On Linux we prefer to see the LWP id */
|
||||
|
@ -98,8 +105,8 @@ static const char* get_tid(void* arg)
|
|||
#else
|
||||
tid = (size_t)GetCurrentThreadId();
|
||||
#endif
|
||||
(void)sprintf(str, "%08" PRIxz, tid);
|
||||
return str;
|
||||
(void)_snprintf(targ->tid, sizeof(targ->tid), "%08" PRIxz, tid);
|
||||
return targ->tid;
|
||||
}
|
||||
|
||||
static BOOL log_invalid_fmt(const char* what)
|
||||
|
@ -230,7 +237,8 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
|
|||
WINPR_ASSERT(layout);
|
||||
WINPR_ASSERT(message);
|
||||
|
||||
char tid[32] = { 0 };
|
||||
struct format_tid_arg targ = { 0 };
|
||||
|
||||
SYSTEMTIME localTime = { 0 };
|
||||
GetLocalTime(&localTime);
|
||||
|
||||
|
@ -266,8 +274,8 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
|
|||
{ ENTRY("%pid"), ENTRY("%u"), NULL, (void*)(size_t)GetCurrentProcessId(), NULL,
|
||||
&recurse }, /* process id */
|
||||
{ ENTRY("%se"), ENTRY("%02u"), NULL, (void*)(size_t)localTime.wSecond, NULL,
|
||||
&recurse }, /* seconds */
|
||||
{ ENTRY("%tid"), ENTRY("%s"), get_tid, tid, NULL, &recurse }, /* thread id */
|
||||
&recurse }, /* seconds */
|
||||
{ ENTRY("%tid"), ENTRY("%s"), get_tid, &targ, NULL, &recurse }, /* thread id */
|
||||
{ ENTRY("%yr"), ENTRY("%u"), NULL, (void*)(size_t)localTime.wYear, NULL,
|
||||
&recurse }, /* year */
|
||||
{ ENTRY("%{"), ENTRY("%}"), NULL, log->context, skip_if_null,
|
||||
|
|
Loading…
Reference in New Issue