From owner-svn-src-stable-12@freebsd.org Wed Oct 21 16:04:57 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EE96E44F34F; Wed, 21 Oct 2020 16:04:57 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CGb15643vz4TRh; Wed, 21 Oct 2020 16:04:57 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AF23085A8; Wed, 21 Oct 2020 16:04:57 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09LG4vWA081806; Wed, 21 Oct 2020 16:04:57 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09LG4vkT081805; Wed, 21 Oct 2020 16:04:57 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <202010211604.09LG4vkT081805@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 21 Oct 2020 16:04:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r366912 - stable/12/lib/libgssapi X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/12/lib/libgssapi X-SVN-Commit-Revision: 366912 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Oct 2020 16:04:58 -0000 Author: brooks Date: Wed Oct 21 16:04:57 2020 New Revision: 366912 URL: https://svnweb.freebsd.org/changeset/base/366912 Log: 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 Modified: stable/12/lib/libgssapi/gss_display_status.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libgssapi/gss_display_status.c ============================================================================== --- stable/12/lib/libgssapi/gss_display_status.c Wed Oct 21 16:00:15 2020 (r366911) +++ stable/12/lib/libgssapi/gss_display_status.c Wed Oct 21 16:04:57 2020 (r366912) @@ -92,6 +92,7 @@ * SUCH DAMAGE. */ +#include #include #include #include @@ -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];