Skip to content

Commit 2803e69

Browse files
committed
Fix -Wimplicit-function-declaration
Clang 16 will make -Wimplicit-function-declaration error by default. For more information, see LWN.net [0] or LLVM's Discourse [1], gentoo-dev@ [2], or the (new) c-std-porting mailing list [3]. [0] https://lwn.net/Articles/913505/ [1] https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213 [2] https://archives.gentoo.org/gentoo-dev/message/dd9f2d3082b8b6f8dfbccb0639e6e240 [3] hosted at lists.linux.dev. Bug: https://bugs.gentoo.org/875527 Signed-off-by: Sam James <sam@gentoo.org>
1 parent 9bf8688 commit 2803e69

File tree

8 files changed

+19
-4
lines changed

8 files changed

+19
-4
lines changed

pb_add.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int pb_add(pb_poly *a, pb_poly *b, pb_poly *c)
1717
pb_poly *tmp;
1818

1919
/* grow c to be the max size */
20-
y = MAX(a->used, b->used);
20+
y = PB_MAX(a->used, b->used);
2121
if (c->alloc < y) {
2222
if ((err = pb_grow(c, y)) != MP_OKAY) {
2323
return err;
@@ -28,7 +28,7 @@ int pb_add(pb_poly *a, pb_poly *b, pb_poly *c)
2828
characteristic = mp_iszero(&(c->characteristic));
2929

3030
/* add the terms */
31-
z = MIN(a->used, b->used);
31+
z = PB_MIN(a->used, b->used);
3232
for (x = 0; x < z; x++) {
3333
if ((err = mp_add(&(a->terms[x]), &(b->terms[x]), &(c->terms[x]))) != MP_OKAY) {
3434
return err;

pb_clear.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Tom St Denis, tomstdenis@iahu.ca, http://poly.libtomcrypt.org
1111
*/
1212
#include <tompoly.h>
13+
#include <stdlib.h>
1314

1415
void pb_clear(pb_poly *a)
1516
{

pb_grow.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* Tom St Denis, tomstdenis@iahu.ca, http://poly.libtomcrypt.org
1111
*/
1212
#include <tompoly.h>
13+
#include <stdlib.h>
14+
#include <string.h>
1315

1416
int pb_grow(pb_poly *a, int size)
1517
{

pb_init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Tom St Denis, tomstdenis@iahu.ca, http://poly.libtomcrypt.org
1111
*/
1212
#include <tompoly.h>
13+
#include <stdlib.h>
1314

1415
/* initialize a */
1516
int pb_init(pb_poly *a, mp_int *characteristic)

pb_init_size.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Tom St Denis, tomstdenis@iahu.ca, http://poly.libtomcrypt.org
1111
*/
1212
#include <tompoly.h>
13+
#include <stdlib.h>
1314

1415
/* initialize a */
1516
int pb_init_size(pb_poly *a, mp_int *characteristic, int size)

pb_shrink.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Tom St Denis, tomstdenis@iahu.ca, http://poly.libtomcrypt.org
1111
*/
1212
#include <tompoly.h>
13+
#include <stdlib.h>
1314

1415
int pb_shrink(pb_poly *a)
1516
{

pb_sub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int pb_sub(pb_poly *a, pb_poly *b, pb_poly *c)
1717
pb_poly *tmp;
1818

1919
/* grow c to be the max size */
20-
y = MAX(a->used, b->used);
20+
y = PB_MAX(a->used, b->used);
2121
if (c->alloc < y) {
2222
if ((err = pb_grow(c, y)) != MP_OKAY) {
2323
return err;
@@ -28,7 +28,7 @@ int pb_sub(pb_poly *a, pb_poly *b, pb_poly *c)
2828
characteristic = mp_iszero(&(c->characteristic));
2929

3030
/* sub the terms */
31-
z = MIN(a->used, b->used);
31+
z = PB_MIN(a->used, b->used);
3232
for (x = 0; x < z; x++) {
3333
if ((err = mp_sub(&(a->terms[x]), &(b->terms[x]), &(c->terms[x]))) != MP_OKAY) {
3434
return err;

tompoly.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,13 @@ int pb_rawsize(pb_poly *a);
112112
int pb_toraw(pb_poly *a, unsigned char *dst);
113113
int pb_readraw(pb_poly *a, unsigned char *buf, int len);
114114

115+
/* What follows should be in a private header, but it's fine for now like that. */
116+
117+
#ifndef PB_MIN
118+
#define PB_MIN(x, y) (((x) < (y)) ? (x) : (y))
119+
#endif
120+
#ifndef PB_MAX
121+
#define PB_MAX(x, y) (((x) > (y)) ? (x) : (y))
122+
#endif
123+
115124
#endif

0 commit comments

Comments
 (0)