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 <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
Adam Langley 2016-08-09 21:25:45 -07:00 committed by CQ bot account: commit-bot@chromium.org
parent 505cf39af9
commit fbe3a7bb61
3 changed files with 8 additions and 8 deletions

View File

@ -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);

View File

@ -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<int>(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",

View File

@ -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. */