summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2020-10-22 16:41:13 +0000
committerBrooks Davis <brooks@FreeBSD.org>2020-10-22 16:41:13 +0000
commitd52c594a6adbfab766e5be4b53f3f9bfc8f61a90 (patch)
treeea9d218bacee01163d0f2fbc7f0b94a0c6a43dc2
parentf7974f56e4b01cc2c471acf607ddca7540b4760d (diff)
downloadsrc-test2-d52c594a6adbfab766e5be4b53f3f9bfc8f61a90.tar.gz
src-test2-d52c594a6adbfab766e5be4b53f3f9bfc8f61a90.zip
MFC r366671:
libgssapi: modernize static string array use Use designated initializers to document positions in the arrays rather than requiring counting. Use nitems() rather than rolling it by hand to count elements. Also, passify a Clang 12 warning about suspcious string concatenation within an array initializer by adding parentheses. Reviewed by: emaste Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26592
Notes
Notes: svn path=/stable/11/; revision=366940
-rw-r--r--lib/libgssapi/gss_display_status.c69
1 files changed, 34 insertions, 35 deletions
diff --git a/lib/libgssapi/gss_display_status.c b/lib/libgssapi/gss_display_status.c
index b2a22d21fb48..1b59c40c4eda 100644
--- a/lib/libgssapi/gss_display_status.c
+++ b/lib/libgssapi/gss_display_status.c
@@ -90,6 +90,7 @@
* SUCH DAMAGE.
*/
+#include <sys/param.h>
#include <gssapi/gssapi.h>
#include <stdio.h>
#include <string.h>
@@ -103,17 +104,15 @@ static const char *
calling_error(OM_uint32 v)
{
static const char *msgs[] = {
- NULL, /* 0 */
- "A required input parameter could not be read.", /* */
- "A required output parameter could not be written.", /* */
- "A parameter was malformed"
+ [0] = "",
+ [1] = "A required input parameter could not be read.",
+ [2] = "A required output parameter could not be written.",
+ [3] = "A parameter was malformed",
};
v >>= GSS_C_CALLING_ERROR_OFFSET;
- if (v == 0)
- return "";
- else if (v >= sizeof(msgs)/sizeof(*msgs))
+ if (v >= nitems(msgs))
return "unknown calling error";
else
return msgs[v];
@@ -123,31 +122,31 @@ static const char *
routine_error(OM_uint32 v)
{
static const char *msgs[] = {
- "Function completed successfully", /* 0 */
- "An unsupported mechanism was requested",
- "An invalid name was supplied",
- "A supplied name was of an unsupported type",
- "Incorrect channel bindings were supplied",
- "An invalid status code was supplied",
- "A token had an invalid MIC",
- "No credentials were supplied, "
- "or the credentials were unavailable or inaccessible.",
- "No context has been established",
- "A token was invalid",
- "A credential was invalid",
- "The referenced credentials have expired",
- "The context has expired",
- "Miscellaneous failure (see text)",
- "The quality-of-protection requested could not be provide",
- "The operation is forbidden by local security policy",
- "The operation or option is not available",
- "The requested credential element already exists",
- "The provided name was not a mechanism name.",
+ [0] = "Function completed successfully",
+ [1] = "An unsupported mechanism was requested",
+ [2] = "An invalid name was supplied",
+ [3] = "A supplied name was of an unsupported type",
+ [4] = "Incorrect channel bindings were supplied",
+ [5] = "An invalid status code was supplied",
+ [6] = "A token had an invalid MIC",
+ [7] = ("No credentials were supplied, "
+ "or the credentials were unavailable or inaccessible."),
+ [8] = "No context has been established",
+ [9] = "A token was invalid",
+ [10] = "A credential was invalid",
+ [11] = "The referenced credentials have expired",
+ [12] = "The context has expired",
+ [13] = "Miscellaneous failure (see text)",
+ [14] = "The quality-of-protection requested could not be provide",
+ [15] = "The operation is forbidden by local security policy",
+ [16] = "The operation or option is not available",
+ [17] = "The requested credential element already exists",
+ [18] = "The provided name was not a mechanism name.",
};
v >>= GSS_C_ROUTINE_ERROR_OFFSET;
- if (v >= sizeof(msgs)/sizeof(*msgs))
+ if (v >= nitems(msgs))
return "unknown routine error";
else
return msgs[v];
@@ -157,17 +156,17 @@ static const char *
supplementary_error(OM_uint32 v)
{
static const char *msgs[] = {
- "normal completion",
- "continuation call to routine required",
- "duplicate per-message token detected",
- "timed-out per-message token detected",
- "reordered (early) per-message token detected",
- "skipped predecessor token(s) detected"
+ [0] = "normal completion",
+ [1] = "continuation call to routine required",
+ [2] = "duplicate per-message token detected",
+ [3] = "timed-out per-message token detected",
+ [4] = "reordered (early) per-message token detected",
+ [5] = "skipped predecessor token(s) detected",
};
v >>= GSS_C_SUPPLEMENTARY_OFFSET;
- if (v >= sizeof(msgs)/sizeof(*msgs))
+ if (v >= nitems(msgs))
return "unknown routine error";
else
return msgs[v];