mirror of
https://github.com/openbsd/src.git
synced 2026-06-18 07:13:36 +02:00
libcrypto/ui: mechanically rename the union _ into u
While mainstream OS use compilers that understand anonymous unions, which would be cleaner here, some special snowflakes rely on LibreSSL in their stacks and they sometimes use very old and special compilers. There is no need to impose a burden on them. There is far more impactful and important cleanup that could be done in the ui pit. This obviates jsg's upcoming removal of a windows-ce workaround. discussed with jsing
This commit is contained in:
+29
-29
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ui_lib.c,v 1.53 2026/05/19 09:17:44 tb Exp $ */
|
||||
/* $OpenBSD: ui_lib.c,v 1.54 2026/05/19 09:23:36 tb Exp $ */
|
||||
/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
|
||||
* project 2001.
|
||||
*/
|
||||
@@ -95,7 +95,7 @@ struct ui_string_st {
|
||||
const char *ok_chars; /* Input */
|
||||
const char *cancel_chars; /* Input */
|
||||
} boolean_data;
|
||||
} _;
|
||||
} u;
|
||||
|
||||
#define OUT_STRING_FREEABLE 0x01
|
||||
int flags; /* flags for internal use */
|
||||
@@ -134,9 +134,9 @@ free_string(UI_STRING *uis)
|
||||
free((char *) uis->out_string);
|
||||
switch (uis->type) {
|
||||
case UIT_BOOLEAN:
|
||||
free((char *)uis->_.boolean_data.action_desc);
|
||||
free((char *)uis->_.boolean_data.ok_chars);
|
||||
free((char *)uis->_.boolean_data.cancel_chars);
|
||||
free((char *)uis->u.boolean_data.action_desc);
|
||||
free((char *)uis->u.boolean_data.ok_chars);
|
||||
free((char *)uis->u.boolean_data.cancel_chars);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -219,9 +219,9 @@ general_allocate_string(UI *ui, const char *prompt, int dup_prompt,
|
||||
if ((s = general_allocate_prompt(prompt, dup_prompt, type, input_flags,
|
||||
result_buf)) == NULL)
|
||||
goto err;
|
||||
s->_.string_data.result_minsize = minsize;
|
||||
s->_.string_data.result_maxsize = maxsize;
|
||||
s->_.string_data.test_buf = test_buf;
|
||||
s->u.string_data.result_minsize = minsize;
|
||||
s->u.string_data.result_maxsize = maxsize;
|
||||
s->u.string_data.test_buf = test_buf;
|
||||
|
||||
if (allocate_string_stack(ui) < 0)
|
||||
goto err;
|
||||
@@ -258,25 +258,25 @@ general_allocate_boolean(UI *ui, const char *prompt, const char *action_desc,
|
||||
|
||||
if (dup_strings) {
|
||||
if (action_desc != NULL) {
|
||||
if ((s->_.boolean_data.action_desc =
|
||||
if ((s->u.boolean_data.action_desc =
|
||||
strdup(action_desc)) == NULL) {
|
||||
UIerror(ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if ((s->_.boolean_data.ok_chars = strdup(ok_chars)) == NULL) {
|
||||
if ((s->u.boolean_data.ok_chars = strdup(ok_chars)) == NULL) {
|
||||
UIerror(ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
if ((s->_.boolean_data.cancel_chars = strdup(cancel_chars)) ==
|
||||
if ((s->u.boolean_data.cancel_chars = strdup(cancel_chars)) ==
|
||||
NULL) {
|
||||
UIerror(ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
s->_.boolean_data.action_desc = action_desc;
|
||||
s->_.boolean_data.ok_chars = ok_chars;
|
||||
s->_.boolean_data.cancel_chars = cancel_chars;
|
||||
s->u.boolean_data.action_desc = action_desc;
|
||||
s->u.boolean_data.ok_chars = ok_chars;
|
||||
s->u.boolean_data.cancel_chars = cancel_chars;
|
||||
}
|
||||
|
||||
if (allocate_string_stack(ui) < 0)
|
||||
@@ -805,7 +805,7 @@ UI_get0_action_string(UI_STRING *uis)
|
||||
switch (uis->type) {
|
||||
case UIT_PROMPT:
|
||||
case UIT_BOOLEAN:
|
||||
return uis->_.boolean_data.action_desc;
|
||||
return uis->u.boolean_data.action_desc;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@@ -836,7 +836,7 @@ UI_get0_test_string(UI_STRING *uis)
|
||||
|
||||
switch (uis->type) {
|
||||
case UIT_VERIFY:
|
||||
return uis->_.string_data.test_buf;
|
||||
return uis->u.string_data.test_buf;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@@ -852,7 +852,7 @@ UI_get_result_minsize(UI_STRING *uis)
|
||||
switch (uis->type) {
|
||||
case UIT_PROMPT:
|
||||
case UIT_VERIFY:
|
||||
return uis->_.string_data.result_minsize;
|
||||
return uis->u.string_data.result_minsize;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@@ -868,7 +868,7 @@ UI_get_result_maxsize(UI_STRING *uis)
|
||||
switch (uis->type) {
|
||||
case UIT_PROMPT:
|
||||
case UIT_VERIFY:
|
||||
return uis->_.string_data.result_maxsize;
|
||||
return uis->u.string_data.result_maxsize;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@@ -889,22 +889,22 @@ UI_set_result(UI *ui, UI_STRING *uis, const char *result)
|
||||
switch (uis->type) {
|
||||
case UIT_PROMPT:
|
||||
case UIT_VERIFY:
|
||||
if (l < uis->_.string_data.result_minsize) {
|
||||
if (l < uis->u.string_data.result_minsize) {
|
||||
ui->flags |= UI_FLAG_REDOABLE;
|
||||
UIerror(UI_R_RESULT_TOO_SMALL);
|
||||
ERR_asprintf_error_data
|
||||
("You must type in %d to %d characters",
|
||||
uis->_.string_data.result_minsize,
|
||||
uis->_.string_data.result_maxsize);
|
||||
uis->u.string_data.result_minsize,
|
||||
uis->u.string_data.result_maxsize);
|
||||
return -1;
|
||||
}
|
||||
if (l > uis->_.string_data.result_maxsize) {
|
||||
if (l > uis->u.string_data.result_maxsize) {
|
||||
ui->flags |= UI_FLAG_REDOABLE;
|
||||
UIerror(UI_R_RESULT_TOO_LARGE);
|
||||
ERR_asprintf_error_data
|
||||
("You must type in %d to %d characters",
|
||||
uis->_.string_data.result_minsize,
|
||||
uis->_.string_data.result_maxsize);
|
||||
uis->u.string_data.result_minsize,
|
||||
uis->u.string_data.result_maxsize);
|
||||
return -1;
|
||||
}
|
||||
if (!uis->result_buf) {
|
||||
@@ -912,7 +912,7 @@ UI_set_result(UI *ui, UI_STRING *uis, const char *result)
|
||||
return -1;
|
||||
}
|
||||
strlcpy(uis->result_buf, result,
|
||||
uis->_.string_data.result_maxsize + 1);
|
||||
uis->u.string_data.result_maxsize + 1);
|
||||
break;
|
||||
case UIT_BOOLEAN:
|
||||
if (!uis->result_buf) {
|
||||
@@ -921,14 +921,14 @@ UI_set_result(UI *ui, UI_STRING *uis, const char *result)
|
||||
}
|
||||
uis->result_buf[0] = '\0';
|
||||
for (p = result; *p; p++) {
|
||||
if (strchr(uis->_.boolean_data.ok_chars, *p)) {
|
||||
if (strchr(uis->u.boolean_data.ok_chars, *p)) {
|
||||
uis->result_buf[0] =
|
||||
uis->_.boolean_data.ok_chars[0];
|
||||
uis->u.boolean_data.ok_chars[0];
|
||||
break;
|
||||
}
|
||||
if (strchr(uis->_.boolean_data.cancel_chars, *p)) {
|
||||
if (strchr(uis->u.boolean_data.cancel_chars, *p)) {
|
||||
uis->result_buf[0] =
|
||||
uis->_.boolean_data.cancel_chars[0];
|
||||
uis->u.boolean_data.cancel_chars[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user