]> eyrie.org Git - kerberos/krb5-strength.git/commitdiff
Fix cppcheck errors
authorRuss Allbery <eagle@eyrie.org>
Mon, 25 Dec 2023 21:29:50 +0000 (13:29 -0800)
committerRuss Allbery <eagle@eyrie.org>
Mon, 25 Dec 2023 21:29:50 +0000 (13:29 -0800)
Fix a few legitimate cppcheck errors and suppress three new false
positives due to cppcheck apparently misparsing noreturn annotations.

plugin/classes.c
plugin/heimdal.c
plugin/sqlite.c
tests/data/cppcheck.supp
tests/tap/kerberos.c

index f7c985a078b4864581745145a4c190e1ca34fda5..ed6c76a2b4d87e42120749406e91773049f1a726 100644 (file)
@@ -4,7 +4,7 @@
  * Checks whether the password satisfies a set of character class rules.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2016 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2016, 2023 Russ Allbery <eagle@eyrie.org>
  * Copyright 2013-2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
@@ -66,7 +66,7 @@ analyze_password(const char *password, struct password_classes *classes)
  */
 static krb5_error_code
 check_rule(krb5_context ctx, struct class_rule *rule, size_t length,
-           struct password_classes *classes)
+           const struct password_classes *classes)
 {
     if (length < rule->min || (rule->max > 0 && length > rule->max))
         return 0;
index 0ca38b42712cae200524801e40db29c5347ca06d..8ace00ab59e7288e559a4b6c2ddb6e942a306075 100644 (file)
@@ -61,8 +61,8 @@ convert_error(krb5_context ctx, krb5_error_code code, const char *prefix,
  */
 static int
 heimdal_pwcheck(krb5_context ctx, krb5_principal principal,
-                krb5_data *password, const char *tuning UNUSED,
-                char *message, size_t length)
+                krb5_data *password, const char *tuning UNUSED, char *message,
+                size_t length)
 {
     krb5_pwqual_moddata data = NULL;
     char *pastring;
index db73aef5144712c837059d11aca7f25c8d4830b5..fae8a630547804773e8a41c5be96f225ba10e1b2 100644 (file)
@@ -147,7 +147,7 @@ common_prefix_length(const char *a, const char *b)
 {
     size_t i;
 
-    for (i = 0; a[i] == b[i] && a[i] != '\0' && b[i] != '\0'; i++)
+    for (i = 0; a[i] == b[i] && a[i] != '\0'; i++)
         ;
     return i;
 }
index c9f8ff100605efe0cd5c1372fb289f2781466594..257cece478906a62751d7803973b3c6b5dc96dcf 100644 (file)
@@ -1,4 +1,4 @@
-// Suppressions file for cppcheck.  -*- conf -*-
+// Suppressions file for cppcheck.
 //
 // This includes suppressions for all of my projects, including files that
 // aren't in rra-c-util, for ease of sharing between projects.  The ones that
@@ -8,7 +8,7 @@
 // with the --xml flag and then add a suppression for the error id, file
 // location, and line.
 //
-// Copyright 2018-2022 Russ Allbery <eagle@eyrie.org>
+// Copyright 2018-2023 Russ Allbery <eagle@eyrie.org>
 //
 // Copying and distribution of this file, with or without modification, are
 // permitted in any medium without royalty provided the copyright notice and
@@ -51,6 +51,11 @@ nullPointerRedundantCheck:portable/krb5-profile.c:61
 nullPointerRedundantCheck:portable/krb5-renew.c:82
 nullPointerRedundantCheck:portable/krb5-renew.c:83
 
+// (krb5-strength) Bug in cppcheck 2.12.0.
+nullPointerRedundantCheck:tests/plugin/heimdal-t.c:81
+nullPointerRedundantCheck:tests/plugin/mit-t.c:91
+nullPointerRedundantCheck:tests/plugin/mit-t.c:97
+
 // Setting the variable to NULL explicitly after deallocation.
 redundantAssignment:tests/pam-util/options-t.c
 
index ae571dcc20936645240a40bd1265c73069370098..5e97f0794e0674ec0d217bf342eaff36c4cd353a 100644 (file)
@@ -15,7 +15,7 @@
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2017, 2022 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2017, 2022, 2023 Russ Allbery <eagle@eyrie.org>
  * Copyright 2006-2007, 2009-2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
@@ -167,7 +167,7 @@ kerberos_kinit(void)
     char *path;
     char principal[BUFSIZ], *command;
     size_t i;
-    int status;
+    int status = 0;
 
     /* Read the principal corresponding to the keytab. */
     path = test_file_path("config/principal");