Skip to content

Commit c9376c2

Browse files
authored
Merge pull request #428 from libtom/pr/fix-gcc-warnings1
fix -Wmissing-declarations -Wmissing-prototypes -Wmissing-noreturn
2 parents b5009d7 + ba8fa04 commit c9376c2

File tree

5 files changed

+46
-44
lines changed

5 files changed

+46
-44
lines changed

demos/ltcrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include <tomcrypt.h>
2020

21-
int usage(char *name)
21+
static int NORETURN usage(char *name)
2222
{
2323
int x;
2424

demos/tv_gen.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
#include "tomcrypt_private.h"
1010

11-
void hash_gen(void)
11+
static void hash_gen(void)
1212
{
1313
unsigned char md[MAXBLOCKSIZE], *buf;
1414
unsigned long outlen, x, y, z;
@@ -49,7 +49,7 @@ void hash_gen(void)
4949
fclose(out);
5050
}
5151

52-
void cipher_gen(void)
52+
static void cipher_gen(void)
5353
{
5454
unsigned char *key, pt[MAXBLOCKSIZE];
5555
unsigned long x, y, z, w;
@@ -124,7 +124,7 @@ void cipher_gen(void)
124124
fclose(out);
125125
}
126126

127-
void hmac_gen(void)
127+
static void hmac_gen(void)
128128
{
129129
unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], *input;
130130
int x, y, z, err;
@@ -176,9 +176,9 @@ void hmac_gen(void)
176176
fclose(out);
177177
}
178178

179-
void omac_gen(void)
180-
{
181179
#ifdef LTC_OMAC
180+
static void omac_gen(void)
181+
{
182182
unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], input[MAXBLOCKSIZE*2+2];
183183
int err, x, y, z, kl;
184184
FILE *out;
@@ -234,12 +234,12 @@ void omac_gen(void)
234234
fprintf(out, "\n");
235235
}
236236
fclose(out);
237-
#endif
238237
}
238+
#endif
239239

240-
void pmac_gen(void)
241-
{
242240
#ifdef LTC_PMAC
241+
static void pmac_gen(void)
242+
{
243243
unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], input[MAXBLOCKSIZE*2+2];
244244
int err, x, y, z, kl;
245245
FILE *out;
@@ -295,12 +295,12 @@ void pmac_gen(void)
295295
fprintf(out, "\n");
296296
}
297297
fclose(out);
298-
#endif
299298
}
299+
#endif
300300

301-
void eax_gen(void)
302-
{
303301
#ifdef LTC_EAX_MODE
302+
static void eax_gen(void)
303+
{
304304
int err, kl, x, y1, z;
305305
FILE *out;
306306
unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2], header[MAXBLOCKSIZE*2],
@@ -361,12 +361,12 @@ void eax_gen(void)
361361
fprintf(out, "\n");
362362
}
363363
fclose(out);
364-
#endif
365364
}
365+
#endif
366366

367-
void ocb_gen(void)
368-
{
369367
#ifdef LTC_OCB_MODE
368+
static void ocb_gen(void)
369+
{
370370
int err, kl, x, y1, z;
371371
FILE *out;
372372
unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
@@ -430,12 +430,12 @@ void ocb_gen(void)
430430
fprintf(out, "\n");
431431
}
432432
fclose(out);
433-
#endif
434433
}
434+
#endif
435435

436-
void ocb3_gen(void)
437-
{
438436
#ifdef LTC_OCB3_MODE
437+
static void ocb3_gen(void)
438+
{
439439
int err, kl, x, y1, z, noncelen;
440440
FILE *out;
441441
unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
@@ -500,12 +500,12 @@ void ocb3_gen(void)
500500
fprintf(out, "\n");
501501
}
502502
fclose(out);
503-
#endif
504503
}
504+
#endif
505505

506-
void ccm_gen(void)
507-
{
508506
#ifdef LTC_CCM_MODE
507+
static void ccm_gen(void)
508+
{
509509
int err, kl, x, y1, z;
510510
FILE *out;
511511
unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
@@ -569,12 +569,12 @@ void ccm_gen(void)
569569
fprintf(out, "\n");
570570
}
571571
fclose(out);
572-
#endif
573572
}
573+
#endif
574574

575-
void gcm_gen(void)
576-
{
577575
#ifdef LTC_GCM_MODE
576+
static void gcm_gen(void)
577+
{
578578
int err, kl, x, y1, z;
579579
FILE *out;
580580
unsigned char key[MAXBLOCKSIZE], plaintext[MAXBLOCKSIZE*2], tag[MAXBLOCKSIZE];
@@ -632,10 +632,10 @@ void gcm_gen(void)
632632
fprintf(out, "\n");
633633
}
634634
fclose(out);
635-
#endif
636635
}
636+
#endif
637637

638-
void base64_gen(void)
638+
static void base64_gen(void)
639639
{
640640
FILE *out;
641641
unsigned char src[32], ch;
@@ -655,11 +655,11 @@ void base64_gen(void)
655655
fclose(out);
656656
}
657657

658-
void math_gen(void)
658+
static void math_gen(void)
659659
{
660660
}
661661

662-
void ecc_gen(void)
662+
static void ecc_gen(void)
663663
{
664664
FILE *out;
665665
unsigned char str[512];
@@ -701,9 +701,9 @@ void ecc_gen(void)
701701
fclose(out);
702702
}
703703

704-
void lrw_gen(void)
705-
{
706704
#ifdef LTC_LRW_MODE
705+
static void lrw_gen(void)
706+
{
707707
FILE *out;
708708
unsigned char tweak[16], key[16], iv[16], buf[1024];
709709
int x, y, err;
@@ -765,8 +765,8 @@ void lrw_gen(void)
765765
lrw_done(&lrw);
766766
}
767767
fclose(out);
768-
#endif
769768
}
769+
#endif
770770

771771
int main(void)
772772
{

tests/der_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ static void der_Xcode_test(void)
13011301
}
13021302

13031303
#ifdef LTC_TEST_READDIR
1304-
int _der_decode_sequence_flexi(const void *in, unsigned long inlen, void* ctx)
1304+
static int _der_decode_sequence_flexi(const void *in, unsigned long inlen, void* ctx)
13051305
{
13061306
ltc_asn1_list** list = ctx;
13071307
if (der_decode_sequence_flexi(in, &inlen, list) == CRYPT_OK) {

tests/ecc_test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static int _ecc_test_mp(void)
209209
return err;
210210
}
211211

212-
int _ecc_old_api(void)
212+
static int _ecc_old_api(void)
213213
{
214214
unsigned char buf[4][4096], ch;
215215
unsigned long x, y, z, s;
@@ -350,7 +350,7 @@ int _ecc_old_api(void)
350350
return CRYPT_OK;
351351
}
352352

353-
int _ecc_new_api(void)
353+
static int _ecc_new_api(void)
354354
{
355355
const char* names[] = {
356356
#ifdef LTC_ECC_SECP112R1
@@ -517,7 +517,7 @@ int _ecc_new_api(void)
517517
return CRYPT_OK;
518518
}
519519

520-
int _ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is)
520+
static int _ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is)
521521
{
522522
if (should_type != is->type) return CRYPT_ERROR;
523523
if (should_type == PK_PRIVATE) {
@@ -536,7 +536,7 @@ int _ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is
536536
return CRYPT_OK;
537537
}
538538

539-
int _ecc_import_export(void) {
539+
static int _ecc_import_export(void) {
540540
const ltc_ecc_curve *cu;
541541
ecc_key key, pri, pub;
542542
unsigned char out[300];

tests/no_prng.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
* The library is free for all purposes without any express
77
* guarantee it works.
88
*/
9+
910
#include "tomcrypt.h"
11+
#include "tomcrypt_test.h"
1012

1113
/**
1214
@file no_prng.c
@@ -29,7 +31,7 @@ typedef struct
2931
@param prng [out] The PRNG state to initialize
3032
@return CRYPT_OK if successful
3133
*/
32-
int no_prng_start(prng_state *prng)
34+
static int no_prng_start(prng_state *prng)
3335
{
3436
no_prng_desc_t *no_prng = (no_prng_desc_t*) prng;
3537
LTC_ARGCHK(no_prng != NULL);
@@ -47,7 +49,7 @@ int no_prng_start(prng_state *prng)
4749
@param prng PRNG state to update
4850
@return CRYPT_OK if successful
4951
*/
50-
int no_prng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng)
52+
static int no_prng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng)
5153
{
5254
no_prng_desc_t *no_prng = (no_prng_desc_t*) prng;
5355
LTC_ARGCHK(no_prng != NULL);
@@ -68,7 +70,7 @@ int no_prng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state
6870
@param prng The PRNG to make active
6971
@return CRYPT_OK if successful
7072
*/
71-
int no_prng_ready(prng_state *prng)
73+
static int no_prng_ready(prng_state *prng)
7274
{
7375
LTC_ARGCHK(prng != NULL);
7476

@@ -82,7 +84,7 @@ int no_prng_ready(prng_state *prng)
8284
@param prng The active PRNG to read from
8385
@return Number of octets read
8486
*/
85-
unsigned long no_prng_read(unsigned char *out, unsigned long outlen, prng_state *prng)
87+
static unsigned long no_prng_read(unsigned char *out, unsigned long outlen, prng_state *prng)
8688
{
8789
no_prng_desc_t *no_prng = (no_prng_desc_t*) prng;
8890
LTC_ARGCHK(no_prng != NULL);
@@ -101,7 +103,7 @@ unsigned long no_prng_read(unsigned char *out, unsigned long outlen, prng_state
101103
@param prng The PRNG to terminate
102104
@return CRYPT_OK if successful
103105
*/
104-
int no_prng_done(prng_state *prng)
106+
static int no_prng_done(prng_state *prng)
105107
{
106108
LTC_UNUSED_PARAM(prng);
107109
return CRYPT_OK;
@@ -114,7 +116,7 @@ int no_prng_done(prng_state *prng)
114116
@param prng The PRNG to export
115117
@return CRYPT_OK if successful
116118
*/
117-
int no_prng_export(unsigned char *out, unsigned long *outlen, prng_state *prng)
119+
static int no_prng_export(unsigned char *out, unsigned long *outlen, prng_state *prng)
118120
{
119121
LTC_UNUSED_PARAM(out);
120122
LTC_UNUSED_PARAM(outlen);
@@ -129,7 +131,7 @@ int no_prng_export(unsigned char *out, unsigned long *outlen, prng_state *prng)
129131
@param prng The PRNG to import
130132
@return CRYPT_OK if successful
131133
*/
132-
int no_prng_import(const unsigned char *in, unsigned long inlen, prng_state *prng)
134+
static int no_prng_import(const unsigned char *in, unsigned long inlen, prng_state *prng)
133135
{
134136
LTC_UNUSED_PARAM(in);
135137
LTC_UNUSED_PARAM(inlen);
@@ -141,7 +143,7 @@ int no_prng_import(const unsigned char *in, unsigned long inlen, prng_state *prn
141143
PRNG self-test
142144
@return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled
143145
*/
144-
int no_prng_test(void)
146+
static int no_prng_test(void)
145147
{
146148
return CRYPT_OK;
147149
}

0 commit comments

Comments
 (0)