diff options
author | Pauli <paul.dale@oracle.com> | 2017-07-27 14:54:27 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2017-07-27 14:54:27 +1000 |
commit | 52b6e17da4c8eea982a19d1a1f34ba24416fb73e (patch) | |
tree | 77ac375597ba0ad55487f06e26a6b10a44d790f4 | |
parent | d67e755418b62fb451ec221c126c9935a06ea63b (diff) |
Fix trivial coding style nits in a_time/a_tm files
Clean up some true/false returns
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/4001)
-rw-r--r-- | crypto/asn1/a_gentm.c | 21 | ||||
-rw-r--r-- | crypto/asn1/a_time.c | 9 | ||||
-rw-r--r-- | crypto/asn1/a_utctm.c | 15 | ||||
-rw-r--r-- | crypto/asn1/asn1_locl.h | 3 |
4 files changed, 23 insertions, 25 deletions
diff --git a/crypto/asn1/a_gentm.c b/crypto/asn1/a_gentm.c index 8b2b66b964..9336b20363 100644 --- a/crypto/asn1/a_gentm.c +++ b/crypto/asn1/a_gentm.c @@ -23,7 +23,7 @@ int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d) if (d->type != V_ASN1_GENERALIZEDTIME) return 0; return asn1_time_to_tm(tm, d); - } +} int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d) { @@ -45,9 +45,9 @@ int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str) return 0; s->type = V_ASN1_GENERALIZEDTIME; } - return (1); - } else - return (0); + return 1; + } + return 0; } ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, @@ -108,7 +108,7 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, return NULL; } -const char *_asn1_mon[12] = { +static const char _asn1_mon[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; @@ -154,13 +154,10 @@ int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) } } - if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s", - _asn1_mon[M - 1], d, h, m, s, f_len, f, y, - (gmt) ? " GMT" : "") <= 0) - return (0); - else - return (1); + return BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s", + _asn1_mon[M - 1], d, h, m, s, f_len, f, y, + (gmt) ? " GMT" : "") > 0; err: BIO_write(bp, "Bad time value", 14); - return (0); + return 0; } diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c index e5b5f9a052..83c57ce7a6 100644 --- a/crypto/asn1/a_time.c +++ b/crypto/asn1/a_time.c @@ -297,8 +297,9 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, if (out == NULL || *out == NULL) { if ((ret = ASN1_GENERALIZEDTIME_new()) == NULL) goto err; - } else + } else { ret = *out; + } /* If already GeneralizedTime just copy across */ if (t->type == V_ASN1_GENERALIZEDTIME) { @@ -349,7 +350,7 @@ int ASN1_TIME_set_string(ASN1_TIME *s, const char *str) return 0; } - if (s && !ASN1_STRING_copy((ASN1_STRING *)s, (ASN1_STRING *)&t)) + if (s != NULL && !ASN1_STRING_copy((ASN1_STRING *)s, (ASN1_STRING *)&t)) return 0; return 1; @@ -421,7 +422,7 @@ int ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm) time(&now_t); memset(tm, 0, sizeof(*tm)); - if (OPENSSL_gmtime(&now_t, tm)) + if (OPENSSL_gmtime(&now_t, tm) != NULL) return 1; return 0; } @@ -448,5 +449,5 @@ int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm) if (tm->type == V_ASN1_GENERALIZEDTIME) return ASN1_GENERALIZEDTIME_print(bp, tm); BIO_write(bp, "Bad time value", 14); - return (0); + return 0; } diff --git a/crypto/asn1/a_utctm.c b/crypto/asn1/a_utctm.c index 2a864180e3..668efa48bb 100644 --- a/crypto/asn1/a_utctm.c +++ b/crypto/asn1/a_utctm.c @@ -112,7 +112,7 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) if (!asn1_utctime_to_tm(&stm, s)) return -2; - if (!OPENSSL_gmtime(&t, &ttm)) + if (OPENSSL_gmtime(&t, &ttm) == NULL) return -2; if (!OPENSSL_gmtime_diff(&day, &sec, &ttm, &stm)) @@ -129,6 +129,11 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) return 0; } +static const char _asn1_mon[12][4] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" +}; + int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm) { const char *v; @@ -159,11 +164,9 @@ int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm) (v[10] >= '0') && (v[10] <= '9') && (v[11] >= '0') && (v[11] <= '9')) s = (v[10] - '0') * 10 + (v[11] - '0'); - if (BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s", - _asn1_mon[M - 1], d, h, m, s, y + 1900, - (gmt) ? " GMT" : "") <= 0) - return 0; - return 1; + return BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s", + _asn1_mon[M - 1], d, h, m, s, y + 1900, + (gmt) ? " GMT" : "") > 0; err: BIO_write(bp, "Bad time value", 14); return 0; diff --git a/crypto/asn1/asn1_locl.h b/crypto/asn1/asn1_locl.h index bf095eaa9f..cee97ab42f 100644 --- a/crypto/asn1/asn1_locl.h +++ b/crypto/asn1/asn1_locl.h @@ -43,9 +43,6 @@ DEFINE_STACK_OF(MIME_PARAM) typedef struct mime_header_st MIME_HEADER; DEFINE_STACK_OF(MIME_HEADER) -/* Month values for printing out times */ -extern const char *_asn1_mon[12]; - void asn1_string_embed_free(ASN1_STRING *a, int embed); int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); |