From fbe3a7bb61b440a8599a794682c1075974c44284 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Tue, 9 Aug 2016 21:25:45 -0700 Subject: [PATCH] Rename the |dont_return_name| flag of |OBJ_obj2txt| to |always_return_oid|. The name of this has been annoying me every time I've seen it over the past couple of days. Having a flag with a negation in the name isn't always bad, but I think this case was. Change-Id: I5922bf4cc94eab8c59256042a9d9acb575bd40aa Reviewed-on: https://boringssl-review.googlesource.com/10242 Reviewed-by: Adam Langley Commit-Queue: Adam Langley CQ-Verified: CQ bot account: commit-bot@chromium.org --- crypto/obj/obj.c | 4 ++-- crypto/obj/obj_test.cc | 8 ++++---- include/openssl/obj.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crypto/obj/obj.c b/crypto/obj/obj.c index bcc54786..c44ffc88 100644 --- a/crypto/obj/obj.c +++ b/crypto/obj/obj.c @@ -454,14 +454,14 @@ static int add_decimal(CBB *out, uint64_t v) { } int OBJ_obj2txt(char *out, int out_len, const ASN1_OBJECT *obj, - int dont_return_name) { + int always_return_oid) { /* Python depends on the empty OID successfully encoding as the empty * string. */ if (obj == NULL || obj->length == 0) { return strlcpy_int(out, "", out_len); } - if (!dont_return_name) { + if (!always_return_oid) { int nid = OBJ_obj2nid(obj); if (nid != NID_undef) { const char *name = OBJ_nid2ln(nid); diff --git a/crypto/obj/obj_test.cc b/crypto/obj/obj_test.cc index 31d02b9c..4813b050 100644 --- a/crypto/obj/obj_test.cc +++ b/crypto/obj/obj_test.cc @@ -95,7 +95,7 @@ static bool TestSignatureAlgorithms() { } static bool ExpectObj2Txt(const uint8_t *der, size_t der_len, - bool dont_return_name, const char *expected) { + bool always_return_oid, const char *expected) { ASN1_OBJECT obj; memset(&obj, 0, sizeof(obj)); obj.data = der; @@ -103,7 +103,7 @@ static bool ExpectObj2Txt(const uint8_t *der, size_t der_len, int expected_len = static_cast(strlen(expected)); - int len = OBJ_obj2txt(nullptr, 0, &obj, dont_return_name); + int len = OBJ_obj2txt(nullptr, 0, &obj, always_return_oid); if (len != expected_len) { fprintf(stderr, "OBJ_obj2txt of %s with out_len = 0 returned %d, wanted %d.\n", @@ -113,7 +113,7 @@ static bool ExpectObj2Txt(const uint8_t *der, size_t der_len, char short_buf[1]; memset(short_buf, 0xff, sizeof(short_buf)); - len = OBJ_obj2txt(short_buf, sizeof(short_buf), &obj, dont_return_name); + len = OBJ_obj2txt(short_buf, sizeof(short_buf), &obj, always_return_oid); if (len != expected_len) { fprintf(stderr, "OBJ_obj2txt of %s with out_len = 1 returned %d, wanted %d.\n", @@ -130,7 +130,7 @@ static bool ExpectObj2Txt(const uint8_t *der, size_t der_len, } char buf[256]; - len = OBJ_obj2txt(buf, sizeof(buf), &obj, dont_return_name); + len = OBJ_obj2txt(buf, sizeof(buf), &obj, always_return_oid); if (len != expected_len) { fprintf(stderr, "OBJ_obj2txt of %s with out_len = 256 returned %d, wanted %d.\n", diff --git a/include/openssl/obj.h b/include/openssl/obj.h index 367cfdc9..88195938 100644 --- a/include/openssl/obj.h +++ b/include/openssl/obj.h @@ -144,7 +144,7 @@ OPENSSL_EXPORT int OBJ_nid2cbb(CBB *out, int nid); OPENSSL_EXPORT ASN1_OBJECT *OBJ_txt2obj(const char *s, int dont_search_names); /* OBJ_obj2txt converts |obj| to a textual representation. If - * |dont_return_name| is zero then |obj| will be matched against known objects + * |always_return_oid| is zero then |obj| will be matched against known objects * and the long (preferably) or short name will be used if found. Otherwise * |obj| will be converted into a dotted sequence of integers. If |out| is not * NULL, then at most |out_len| bytes of the textual form will be written @@ -152,7 +152,7 @@ OPENSSL_EXPORT ASN1_OBJECT *OBJ_txt2obj(const char *s, int dont_search_names); * always be NUL terminated. It returns the number of characters that could * have been written, not including the final NUL, or -1 on error. */ OPENSSL_EXPORT int OBJ_obj2txt(char *out, int out_len, const ASN1_OBJECT *obj, - int dont_return_name); + int always_return_oid); /* Adding objects at runtime. */