From 929e2e8f7af281c5eb4fa07758930d542ec43d97 Mon Sep 17 00:00:00 2001 From: Etienne Dechamps Date: Fri, 14 Jul 2023 23:36:05 +0100 Subject: [PATCH] Fix MSVC warning C4018 signed/unsigned mismatch (#821) See #810 --- CMakeLists.txt | 1 - qa/loopback/src/paqa.c | 6 +++--- qa/paqa_devs.c | 2 +- qa/paqa_latency.c | 8 ++++---- src/hostapi/jack/pa_jack.c | 2 +- test/patest_latency.c | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 194a92a36..87d0bb832 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,6 @@ if(PA_WARNINGS_ARE_ERRORS) # "Grandfathered" warnings that existed before we started enforcement. # Do *NOT* add warnings to this list. Instead, fix your code so that it doesn't produce the warning. # TODO: fix the offending code so that we don't have to exclude specific warnings anymore. - /wd4018 # W3 signed/unsigned mismatch /wd4244 # W2 conversion possible loss of data /wd4267 # W3 conversion possible loss of data /wd4996 # W3 unsafe/deprecated diff --git a/qa/loopback/src/paqa.c b/qa/loopback/src/paqa.c index 0427d83c1..909916b13 100644 --- a/qa/loopback/src/paqa.c +++ b/qa/loopback/src/paqa.c @@ -120,8 +120,8 @@ typedef struct LoopbackContext_s volatile int minInputOutputDelta; volatile int maxInputOutputDelta; - int minFramesPerBuffer; - int maxFramesPerBuffer; + unsigned long minFramesPerBuffer; + unsigned long maxFramesPerBuffer; int primingCount; TestParameters *test; volatile int done; @@ -849,7 +849,7 @@ static int PaQa_SingleLoopBackTest( UserOptions *userOptions, TestParameters *te { double latencyMSec; - printf( "%4d-%4d | ", + printf( "%4lu-%4lu | ", loopbackContext.minFramesPerBuffer, loopbackContext.maxFramesPerBuffer ); diff --git a/qa/paqa_devs.c b/qa/paqa_devs.c index c90ff8c70..1a70e842d 100644 --- a/qa/paqa_devs.c +++ b/qa/paqa_devs.c @@ -225,7 +225,7 @@ static int QaCallback( const void *inputData, void *userData ) { unsigned long frameIndex; - unsigned long channelIndex; + int channelIndex; float sample; PaQaData *data = (PaQaData *) userData; const PaQaTestParameters *parameters = data->parameters; diff --git a/qa/paqa_latency.c b/qa/paqa_latency.c index a70807b51..9f468bf53 100644 --- a/qa/paqa_latency.c +++ b/qa/paqa_latency.c @@ -61,8 +61,8 @@ typedef struct int left_phase; int right_phase; char message[20]; - int minFramesPerBuffer; - int maxFramesPerBuffer; + unsigned long minFramesPerBuffer; + unsigned long maxFramesPerBuffer; int callbackCount; PaTime minDeltaDacTime; PaTime maxDeltaDacTime; @@ -170,8 +170,8 @@ PaError paqaCheckLatency( PaStreamParameters *outputParamsPtr, printf("Play for %d seconds.\n", NUM_SECONDS ); Pa_Sleep( NUM_SECONDS * 1000 ); - printf(" minFramesPerBuffer = %4d\n", dataPtr->minFramesPerBuffer ); - printf(" maxFramesPerBuffer = %4d\n", dataPtr->maxFramesPerBuffer ); + printf(" minFramesPerBuffer = %4lu\n", dataPtr->minFramesPerBuffer ); + printf(" maxFramesPerBuffer = %4lu\n", dataPtr->maxFramesPerBuffer ); printf(" minDeltaDacTime = %f\n", dataPtr->minDeltaDacTime ); printf(" maxDeltaDacTime = %f\n", dataPtr->maxDeltaDacTime ); diff --git a/src/hostapi/jack/pa_jack.c b/src/hostapi/jack/pa_jack.c index 746885fb6..5c20b4420 100644 --- a/src/hostapi/jack/pa_jack.c +++ b/src/hostapi/jack/pa_jack.c @@ -507,7 +507,7 @@ static PaError BuildDeviceList( PaJackHostApiRepresentation *jackApi ) // Add 1 for null terminator. size_t device_name_regex_escaped_size = jack_client_name_size() * 2 + 1; size_t port_regex_size = device_name_regex_escaped_size + strlen(port_regex_suffix); - int port_index, client_index, i; + unsigned long port_index, client_index, i; double globalSampleRate; regex_t port_regex; unsigned long numClients = 0, numPorts = 0; diff --git a/test/patest_latency.c b/test/patest_latency.c index 7f622c131..d0e4f3e02 100644 --- a/test/patest_latency.c +++ b/test/patest_latency.c @@ -93,7 +93,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer, { paTestData *data = (paTestData*)userData; float *out = (float*)outputBuffer; - int i; + unsigned long i; (void) inputBuffer; /* Prevent unused variable warning. */