Skip to content

Commit 41da295

Browse files
committed
Suppress printf format warnings
* Add `printf` format attribute to `ossl_raise`. * Fix a format specifier in `config_load_bio`. * Use `ASSUME` for the unreachable condition.
1 parent 74731d9 commit 41da295

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

ext/openssl/ossl.c

+2
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ ossl_to_der_if_possible(VALUE obj)
265265
return obj;
266266
}
267267

268+
PRINTF_ARGS(static VALUE ossl_make_error(VALUE exc, const char *fmt, va_list args), 2, 0);
269+
268270
/*
269271
* Errors
270272
*/

ext/openssl/ossl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ int ossl_pem_passwd_cb(char *, int, int, void *);
120120
/*
121121
* ERRor messages
122122
*/
123-
NORETURN(void ossl_raise(VALUE, const char *, ...));
123+
PRINTF_ARGS(NORETURN(void ossl_raise(VALUE, const char *, ...)), 2, 3);
124124
/* Clear OpenSSL error queue. If dOSSL is set, rb_warn() them. */
125125
void ossl_clear_error(void);
126126

ext/openssl/ossl_config.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ config_load_bio(CONF *conf, BIO *bio)
6060
if (eline <= 0)
6161
ossl_raise(eConfigError, "wrong config format");
6262
else
63-
ossl_raise(eConfigError, "error in line %d", eline);
63+
ossl_raise(eConfigError, "error in line %ld", eline);
6464
}
6565
BIO_free(bio);
6666

ext/openssl/ossl_pkey_ec.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,10 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
596596
ossl_raise(rb_eArgError, "wrong number of arguments");
597597
}
598598

599-
if (group == NULL)
600-
ossl_raise(eEC_GROUP, "");
599+
#if !defined(LIKELY) && !defined(RB_LIKELY)
600+
#define LIKELY(x) (x)
601+
#endif
602+
ASSUME(group);
601603
RTYPEDDATA_DATA(self) = group;
602604

603605
return self;

0 commit comments

Comments
 (0)