Skip to content

Commit 7114f57

Browse files
committed
CDRIVER-3701 fix TRACE macro warnings
1 parent e2a5320 commit 7114f57

File tree

7 files changed

+30
-26
lines changed

7 files changed

+30
-26
lines changed

.evergreen/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,7 @@ tasks:
11651165
script: |-
11661166
set -o errexit
11671167
set -o xtrace
1168+
export CFLAGS="-Werror -Wno-cast-align"
11681169
export DEBUG="ON"
11691170
export TRACING="ON"
11701171
CC='${CC}' MARCH='${MARCH}' sh .evergreen/compile.sh

build/evergreen_config_lib/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def __init__(self, task_name, extra_commands, orchestration=True, **kwargs):
251251
exit 123
252252
fi''')]),
253253
CompileTask('compile-tracing',
254-
TRACING='ON'),
254+
TRACING='ON', CFLAGS='-Werror -Wno-cast-align'),
255255
CompileTask('release-compile',
256256
config='release',
257257
depends_on=OD([('name', 'make-release-archive'),

src/libmongoc/src/mongoc/mongoc-crypt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ _log_callback (mongocrypt_log_level_t mongocrypt_log_level,
5555
case MONGOCRYPT_LOG_LEVEL_TRACE:
5656
log_level = MONGOC_LOG_LEVEL_TRACE;
5757
break;
58+
default:
59+
log_level = MONGOC_LOG_LEVEL_CRITICAL;
60+
break;
5861
}
5962

6063
mongoc_log (log_level, MONGOC_LOG_DOMAIN, "%s", message);

src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ _mongoc_stream_tls_secure_channel_destroy (mongoc_stream_t *stream)
107107
* Shutting Down an Schannel Connection
108108
*/
109109

110-
TRACE ("shutting down SSL/TLS connection", NULL);
110+
TRACE ("%s", "shutting down SSL/TLS connection");
111111

112112
if (secure_channel->cred && secure_channel->ctxt) {
113113
SecBufferDesc BuffDesc;
@@ -164,7 +164,7 @@ _mongoc_stream_tls_secure_channel_destroy (mongoc_stream_t *stream)
164164

165165
/* free SSPI Schannel API security context handle */
166166
if (secure_channel->ctxt) {
167-
TRACE ("clear security context handle", NULL);
167+
TRACE ("%s", "clear security context handle");
168168
DeleteSecurityContext (&secure_channel->ctxt->ctxt_handle);
169169
bson_free (secure_channel->ctxt);
170170
}
@@ -173,7 +173,7 @@ _mongoc_stream_tls_secure_channel_destroy (mongoc_stream_t *stream)
173173
if (secure_channel->cred) {
174174
/* decrement the reference counter of the credential/session handle */
175175
/* if the handle was not cached and the refcount is zero */
176-
TRACE ("clear credential handle", NULL);
176+
TRACE ("%s", "clear credential handle");
177177
FreeCredentialsHandle (&secure_channel->cred->cred_handle);
178178
bson_free (secure_channel->cred);
179179
}
@@ -371,7 +371,7 @@ _mongoc_stream_tls_secure_channel_writev (mongoc_stream_t *stream,
371371
BSON_ASSERT (secure_channel);
372372
ENTRY;
373373

374-
TRACE ("Trying to write to the server", NULL);
374+
TRACE ("%s", "Trying to write to the server");
375375
tls->timeout_msec = timeout_msec;
376376

377377
TRACE ("count: %d, 0th: %lu", iovcnt, iov[0].iov_len);
@@ -587,7 +587,7 @@ _mongoc_stream_tls_secure_channel_decrypt (
587587

588588
/* check if server wants to renegotiate the connection context */
589589
if (sspi_status == SEC_I_RENEGOTIATE) {
590-
TRACE ("remote party requests renegotiation", NULL);
590+
TRACE ("%s", "remote party requests renegotiation");
591591
}
592592
/* check if the server closed the connection */
593593
else if (sspi_status == SEC_I_CONTEXT_EXPIRED) {
@@ -597,11 +597,11 @@ _mongoc_stream_tls_secure_channel_decrypt (
597597

598598
if (!secure_channel->recv_connection_closed) {
599599
secure_channel->recv_connection_closed = true;
600-
TRACE ("server closed the connection", NULL);
600+
TRACE ("%s", "server closed the connection");
601601
}
602602
}
603603
} else if (sspi_status == SEC_E_INCOMPLETE_MESSAGE) {
604-
TRACE ("failed to decrypt data, need more data", NULL);
604+
TRACE ("%s", "failed to decrypt data, need more data");
605605
} else {
606606
TRACE ("failed to read data from server: %d", sspi_status);
607607
secure_channel->recv_unrecoverable_err = true;
@@ -639,7 +639,7 @@ _mongoc_stream_tls_secure_channel_read (mongoc_stream_t *stream,
639639
*/
640640

641641
if (secure_channel->decdata_offset) {
642-
TRACE ("decrypted data is already available", NULL);
642+
TRACE ("%s", "decrypted data is already available");
643643
return _mongoc_stream_tls_secure_channel_debuf (secure_channel, buf, len);
644644
}
645645

@@ -654,17 +654,17 @@ _mongoc_stream_tls_secure_channel_read (mongoc_stream_t *stream,
654654

655655
/* keep these checks separated, for more detailed tracing */
656656
if (secure_channel->recv_unrecoverable_err) {
657-
TRACE ("an unrecoverable error occurred in a prior call", NULL);
657+
TRACE ("%s", "an unrecoverable error occurred in a prior call");
658658
return -1;
659659
}
660660

661661
if (secure_channel->recv_sspi_close_notify) {
662-
TRACE ("server indicated shutdown in a prior call", NULL);
662+
TRACE ("%s", "server indicated shutdown in a prior call");
663663
return -1;
664664
}
665665

666666
if (secure_channel->recv_connection_closed) {
667-
TRACE ("connection closed", NULL);
667+
TRACE ("%s", "connection closed");
668668
return -1;
669669
}
670670

@@ -679,7 +679,7 @@ _mongoc_stream_tls_secure_channel_read (mongoc_stream_t *stream,
679679

680680
if (!nread) {
681681
if (MONGOC_ERRNO_IS_AGAIN (errno)) {
682-
TRACE ("Try again", NULL);
682+
TRACE ("%s", "Try again");
683683
return 0;
684684
} else {
685685
secure_channel->recv_connection_closed = true;
@@ -836,11 +836,11 @@ mongoc_stream_tls_secure_channel_handshake (mongoc_stream_t *stream,
836836

837837

838838
if (mongoc_secure_channel_handshake_step_1 (tls, (char *) host)) {
839-
TRACE ("Step#1 Worked!\n\n", NULL);
839+
TRACE ("%s", "Step#1 Worked!\n\n");
840840
*events = POLLIN;
841841
RETURN (false);
842842
} else {
843-
TRACE ("Step#1 FAILED!", NULL);
843+
TRACE ("%s", "Step#1 FAILED!");
844844
}
845845

846846
break;
@@ -857,25 +857,25 @@ mongoc_stream_tls_secure_channel_handshake (mongoc_stream_t *stream,
857857
}
858858
RETURN (false);
859859
} else {
860-
TRACE ("Step#2 FAILED!", NULL);
860+
TRACE ("%s", "Step#2 FAILED!");
861861
}
862862

863863
break;
864864

865865
case ssl_connect_3:
866866

867867
if (mongoc_secure_channel_handshake_step_3 (tls, (char *) host)) {
868-
TRACE ("Step#3 Worked!\n\n", NULL);
868+
TRACE ("%s", "Step#3 Worked!\n\n");
869869
*events = POLLIN | POLLOUT;
870870
RETURN (false);
871871
} else {
872-
TRACE ("Step#3 FAILED!", NULL);
872+
TRACE ("%s", "Step#3 FAILED!");
873873
}
874874

875875
break;
876876

877877
case ssl_connect_done:
878-
TRACE ("Connect DONE!", NULL);
878+
TRACE ("%s", "Connect DONE!");
879879
/* reset our connection state machine */
880880
secure_channel->connecting_state = ssl_connect_1;
881881
RETURN (true);
@@ -961,7 +961,7 @@ mongoc_stream_tls_secure_channel_new (mongoc_stream_t *base_stream,
961961
tls->timeout_msec = -1;
962962
tls->base_stream = base_stream;
963963

964-
TRACE ("SSL/TLS connection with endpoint AcquireCredentialsHandle", NULL);
964+
TRACE ("%s", "SSL/TLS connection with endpoint AcquireCredentialsHandle");
965965

966966
/* setup Schannel API options */
967967
memset (&schannel_cred, 0, sizeof (schannel_cred));
@@ -978,15 +978,15 @@ mongoc_stream_tls_secure_channel_new (mongoc_stream_t *base_stream,
978978
schannel_cred.dwFlags |= SCH_CRED_MANUAL_CRED_VALIDATION |
979979
SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
980980
SCH_CRED_IGNORE_REVOCATION_OFFLINE;
981-
TRACE ("disabled server certificate checks", NULL);
981+
TRACE ("%s", "disabled server certificate checks");
982982
} else if (_mongoc_ssl_opts_disable_certificate_revocation_check (opt)) {
983983
schannel_cred.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
984984
SCH_CRED_IGNORE_REVOCATION_OFFLINE;
985-
TRACE ("disabled server certificate revocation checks", NULL);
985+
TRACE ("%s", "disabled server certificate revocation checks");
986986
} else {
987987
schannel_cred.dwFlags |=
988988
SCH_CRED_AUTO_CRED_VALIDATION | SCH_CRED_REVOCATION_CHECK_CHAIN;
989-
TRACE ("enabled server certificate checks", NULL);
989+
TRACE ("%s", "enabled server certificate checks");
990990
}
991991

992992
if (opt->allow_invalid_hostname) {

src/libmongoc/src/mongoc/mongoc-topology-description.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ mongoc_topology_description_handle_ismaster (
19981998

19991999
if (wrong_set_name) {
20002000
/* Replace with unknown. */
2001-
TRACE ("wrong set name", NULL);
2001+
TRACE ("%s", "wrong set name");
20022002
mongoc_server_description_handle_ismaster (sd, NULL, 0, &set_name_err);
20032003
}
20042004
}

src/libmongoc/src/mongoc/mongoc-topology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ mongoc_topology_rescan_srv (mongoc_topology_t *topology)
637637
return;
638638
}
639639

640-
TRACE ("Polling for SRV records", NULL);
640+
TRACE ("%s", "Polling for SRV records");
641641

642642
/* Go forth and query... */
643643
prefixed_service = bson_strdup_printf ("_mongodb._tcp.%s", service);

src/libmongoc/tests/test-mongoc-topology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ checks_cleanup (checks_t *checks)
4040
static bool
4141
checks_cmp (checks_t *checks, const char *metric, char cmp, int expected)
4242
{
43-
int actual;
43+
int actual = 0;
4444

4545
bson_mutex_lock (&checks->mutex);
4646
if (0 == strcmp (metric, "n_started")) {

0 commit comments

Comments
 (0)