Skip to content

Commit fd8eef3

Browse files
authored
MONGOCRYPT-783 address miscellaneous warnings (#975)
* Silence -Wold-style-cast for C++ compatibility code * Address -Wmissing-prototype and -Wmissing-variable-declarations warnings * Address -Wundef warnings * Address -Wvla warnings * Address -Wunreachable-code-break warnings * Address -Wassign-enum warnings * Address -Wunused-macros warnings
1 parent 7d799f5 commit fd8eef3

File tree

68 files changed

+259
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+259
-217
lines changed

kms-message/src/hexlify.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include "hexlify.h"
18+
19+
//
20+
1721
#include "kms_message_private.h"
22+
1823
#include <stdint.h>
1924
#include <stdio.h>
2025
#include <stdlib.h>

kms-message/src/kms_request.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ kms_request_get_signature (kms_request_t *request)
744744
return kms_request_str_detach (sig);
745745
}
746746

747-
void
747+
static void
748748
kms_request_validate (kms_request_t *request)
749749
{
750750
if (!check_and_prohibit_kmip (request)) {

kms-message/src/kms_request_str.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#include <stdlib.h>
2828
#include <limits.h> /* CHAR_BIT */
2929

30-
bool rfc_3986_tab[256] = {0};
31-
bool kms_initialized = false;
30+
static bool rfc_3986_tab[256] = {0};
31+
static bool kms_initialized = false;
3232

3333
static void
3434
tables_init (void)
@@ -126,12 +126,6 @@ kms_request_str_detach (kms_request_str_t *str)
126126
return r;
127127
}
128128

129-
const char *
130-
kms_request_str_get (kms_request_str_t *str)
131-
{
132-
return str->str;
133-
}
134-
135129
bool
136130
kms_request_str_reserve (kms_request_str_t *str, size_t size)
137131
{

kms-message/src/kms_response_parser.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ kms_response_parser_wants_bytes (kms_response_parser_t *parser, int32_t max)
8181
default:
8282
KMS_ASSERT (false && "Invalid kms_response_parser HTTP state");
8383
}
84-
return -1;
8584
}
8685

8786
static bool

kms-message/src/sort.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@
3737
* https://github.com/freebsd/freebsd/blob/e7c6cef9514d3bb1f14a30a5ee871231523e43db/lib/libc/stdlib/merge.c
3838
*/
3939

40+
#include "sort.h"
41+
42+
//
43+
4044
#include <stddef.h>
4145

4246
/*
4347
* This is to avoid out-of-bounds addresses in sorting the
4448
* last 4 elements.
4549
*/
4650

47-
typedef int (*cmp_t) (const void *, const void *);
4851
#define CMP(x, y) cmp (x, y)
4952
#define swap(a, b) \
5053
{ \

kms-message/src/sort.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
#include <stddef.h>
19+
1820
typedef int (*cmp_t) (const void *, const void *);
1921

2022
void

kms-message/test/test_kmip_reader_writer.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* You may obtain a copy of the License at
77
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -54,6 +54,7 @@ kms_kmip_writer_test_evaluate (kmip_writer_t *writer,
5454
free (expected_hex);
5555
}
5656

57+
void kms_kmip_writer_test (void); // -Wmissing-prototypes: for testing only.
5758
void
5859
kms_kmip_writer_test (void)
5960
{
@@ -140,6 +141,7 @@ kms_kmip_writer_test (void)
140141
kmip_writer_destroy (writer);
141142
}
142143

144+
void kms_kmip_reader_test (void); // -Wmissing-prototypes: for testing only.
143145
void
144146
kms_kmip_reader_test (void)
145147
{
@@ -312,6 +314,7 @@ kms_kmip_reader_test (void)
312314
free (data);
313315
}
314316

317+
void kms_kmip_reader_negative_int_test (void); // -Wmissing-prototypes: for testing only.
315318
void
316319
kms_kmip_reader_negative_int_test (void)
317320
{
@@ -356,6 +359,7 @@ kms_kmip_reader_negative_int_test (void)
356359
free (data);
357360
}
358361

362+
void kms_kmip_reader_find_test (void); // -Wmissing-prototypes: for testing only.
359363
void
360364
kms_kmip_reader_find_test (void)
361365
{
@@ -404,6 +408,7 @@ kms_kmip_reader_find_test (void)
404408
free (data);
405409
}
406410

411+
void kms_kmip_reader_find_and_recurse_test (void); // -Wmissing-prototypes: for testing only.
407412
void
408413
kms_kmip_reader_find_and_recurse_test (void)
409414
{
@@ -438,6 +443,7 @@ kms_kmip_reader_find_and_recurse_test (void)
438443
free (data);
439444
}
440445

446+
void kms_kmip_reader_find_and_read_enum_test (void); // -Wmissing-prototypes: for testing only.
441447
void
442448
kms_kmip_reader_find_and_read_enum_test (void)
443449
{
@@ -470,6 +476,7 @@ kms_kmip_reader_find_and_read_enum_test (void)
470476
free (data);
471477
}
472478

479+
void kms_kmip_reader_find_and_read_bytes_test (void); // -Wmissing-prototypes: for testing only.
473480
void
474481
kms_kmip_reader_find_and_read_bytes_test (void)
475482
{

kms-message/test/test_kms_kmip_request.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ value="ffa8cc79e8c3763b0121fcd06bb3488c8bf42c0774604640279b16b264194030eeb083962
7676
0x36, 0xa9, 0x06, 0x6b, 0x4e, 0x10, 0xae, 0xb5, 0x6a, 0x5c, 0xcf, 0x6a, \
7777
0xa4, 0x69, 0x01, 0xe6, 0x25, 0xe3, 0x40, 0x0c, 0x78, 0x11, 0xd2, 0xec
7878

79+
void kms_kmip_request_register_secretdata_test (void); // -Wmissing-prototypes: for testing only.
7980
void
8081
kms_kmip_request_register_secretdata_test (void)
8182
{
@@ -98,6 +99,7 @@ kms_kmip_request_register_secretdata_test (void)
9899
kms_request_destroy (req);
99100
}
100101

102+
void kms_kmip_request_register_secretdata_invalid_test (void); // -Wmissing-prototypes: for testing only.
101103
void
102104
kms_kmip_request_register_secretdata_invalid_test (void)
103105
{
@@ -144,6 +146,7 @@ value="7FJYvnV6XkaUCWuY96bCSc6AuhvkPpqI"/>
144146
0x58, 0x6b, 0x61, 0x55, 0x43, 0x57, 0x75, 0x59, 0x39, 0x36, 0x62, 0x43, \
145147
0x53, 0x63, 0x36, 0x41, 0x75, 0x68, 0x76, 0x6b, 0x50, 0x70, 0x71, 0x49
146148

149+
void kms_kmip_request_get_test (void); // -Wmissing-prototypes: for testing only.
147150
void
148151
kms_kmip_request_get_test (void)
149152
{
@@ -200,6 +203,7 @@ value="7FJYvnV6XkaUCWuY96bCSc6AuhvkPpqI"/>
200203
0x58, 0x6b, 0x61, 0x55, 0x43, 0x57, 0x75, 0x59, 0x39, 0x36, 0x62, 0x43, \
201204
0x53, 0x63, 0x36, 0x41, 0x75, 0x68, 0x76, 0x6b, 0x50, 0x70, 0x71, 0x49
202205

206+
void kms_kmip_request_activate_test (void); // -Wmissing-prototypes: for testing only.
203207
void
204208
kms_kmip_request_activate_test (void)
205209
{

kms-message/test/test_kms_kmip_response.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static const uint8_t SUCCESS_REGISTER_RESPONSE[] = {
5656

5757
static const char *const SUCCESS_REGISTER_RESPONSE_UNIQUE_IDENTIFIER = "39";
5858

59+
void kms_kmip_response_get_unique_identifier_test (void); // -Wmissing-prototypes: for testing only.
5960
void
6061
kms_kmip_response_get_unique_identifier_test (void)
6162
{
@@ -141,6 +142,7 @@ static const uint8_t SUCCESS_GET_RESPONSE_SECRETDATA[] = {
141142
0x36, 0xa9, 0x06, 0x6b, 0x4e, 0x10, 0xae, 0xb5, 0x6a, 0x5c, 0xcf, 0x6a,
142143
0xa4, 0x69, 0x01, 0xe6, 0x25, 0xe3, 0x40, 0x0c, 0x78, 0x11, 0xd2, 0xec};
143144

145+
void kms_kmip_response_get_secretdata_test (void); // -Wmissing-prototypes: for testing only.
144146
void
145147
kms_kmip_response_get_secretdata_test (void)
146148
{
@@ -197,6 +199,7 @@ static const uint8_t ERROR_GET_RESPOSE_NOTFOUND[] = {
197199
0x6c, 0x74, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x4e,
198200
0x6f, 0x74, 0x46, 0x6f, 0x75, 0x6e, 0x64};
199201

202+
void kms_kmip_response_get_secretdata_notfound_test (void); // -Wmissing-prototypes: for testing only.
200203
void
201204
kms_kmip_response_get_secretdata_notfound_test (void)
202205
{

kms-message/test/test_kms_kmip_response_parser.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static const int SAMPLE_KMIP_FIRST_LENGTH = 32;
3636
/* SAMPLE_KMIP_LARGE_LENGTH is a byte size larger than the message. */
3737
static const int SAMPLE_KMIP_LARGE_LENGTH = 1024;
3838

39+
void kms_kmip_response_parser_test (void); // -Wmissing-prototypes: for testing only.
3940
void
4041
kms_kmip_response_parser_test (void)
4142
{
@@ -118,6 +119,7 @@ feed_full_response (kms_response_parser_t *parser, uint8_t *data)
118119
}
119120
}
120121

122+
void kms_kmip_response_parser_reuse_test (void); // -Wmissing-prototypes: for testing only.
121123
void
122124
kms_kmip_response_parser_reuse_test (void)
123125
{
@@ -150,6 +152,7 @@ kms_kmip_response_parser_reuse_test (void)
150152
free (data);
151153
}
152154

155+
void kms_kmip_response_parser_excess_test (void); // -Wmissing-prototypes: for testing only.
153156
void
154157
kms_kmip_response_parser_excess_test (void)
155158
{
@@ -171,6 +174,7 @@ kms_kmip_response_parser_excess_test (void)
171174
free (data);
172175
}
173176

177+
void kms_kmip_response_parser_notenough_test (void); // -Wmissing-prototypes: for testing only.
174178
void
175179
kms_kmip_response_parser_notenough_test (void)
176180
{

0 commit comments

Comments
 (0)