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
This commit is contained in:
parent
b9aa4537b2
commit
155e586513
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user