aboutsummaryrefslogtreecommitdiff
path: root/lib/libgssapi/gss_display_status.c
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2020-10-13 17:14:30 +0000
committerBrooks Davis <brooks@FreeBSD.org>2020-10-13 17:14:30 +0000
commit155e58651386d0a71147138513e6eb35d4a207c3 (patch)
tree9060d1c77516f963695bc836d2607f4da1c5ef83 /lib/libgssapi/gss_display_status.c
parentb9aa4537b2155a0b0bb419ff05b8da206c02bfbd (diff)
downloadsrc-155e58651386d0a71147138513e6eb35d4a207c3.tar.gz
src-155e58651386d0a71147138513e6eb35d4a207c3.zip
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 MFC after: 1 week Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26592
Notes
Notes: svn path=/head/; revision=366671
Diffstat (limited to 'lib/libgssapi/gss_display_status.c')
-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 b8ff12c4c3cb..55ca83ce9aa8 100644
--- a/lib/libgssapi/gss_display_status.c
+++ b/lib/libgssapi/gss_display_status.c
@@ -92,6 +92,7 @@
* SUCH DAMAGE.
*/
+#include <sys/param.h>
#include <gssapi/gssapi.h>
#include <stdio.h>
#include <string.h>
@@ -105,17 +106,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];
@@ -125,31 +124,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];
@@ -159,17 +158,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];