[openssl-commits] [openssl] master update
paul.dale at oracle.com
paul.dale at oracle.com
Thu Jul 27 04:54:39 UTC 2017
The branch master has been updated
via 52b6e17da4c8eea982a19d1a1f34ba24416fb73e (commit)
from d67e755418b62fb451ec221c126c9935a06ea63b (commit)
- Log -----------------------------------------------------------------
commit 52b6e17da4c8eea982a19d1a1f34ba24416fb73e
Author: Pauli <paul.dale at oracle.com>
Date: Thu Jul 27 14:54:27 2017 +1000
Fix trivial coding style nits in a_time/a_tm files
Clean up some true/false returns
Reviewed-by: Andy Polyakov <appro at openssl.org>
Reviewed-by: Paul Dale <paul.dale at oracle.com>
(Merged from https://github.com/openssl/openssl/pull/4001)
-----------------------------------------------------------------------
Summary of changes:
crypto/asn1/a_gentm.c | 21 +++++++++------------
crypto/asn1/a_time.c | 9 +++++----
crypto/asn1/a_utctm.c | 15 +++++++++------
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 8b2b66b..9336b20 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 e5b5f9a..83c57ce 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 2a86418..668efa4 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 bf095ea..cee97ab 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);
More information about the openssl-commits
mailing list