]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4483] addressed review comments
authorRazvan Becheriu <razvan@isc.org>
Fri, 22 May 2026 09:40:50 +0000 (12:40 +0300)
committerRazvan Becheriu <razvan@isc.org>
Fri, 22 May 2026 13:15:04 +0000 (13:15 +0000)
src/hooks/dhcp/mysql/mysql_host_data_source.cc
src/hooks/dhcp/mysql/mysql_legal_log.cc
tools/valgrind_generate_suppression_file.sh

index 16740f4fe6941aae6cdf77b99c7dc15ba514156d..01401ea2f81b42ecc5f6d2f4ae682c8ef5e09360 100644 (file)
@@ -1493,6 +1493,8 @@ public:
         columns_[iaid_index_] = "dhcp6_iaid";
         columns_[excluded_prefix_index_] = "excluded_prefix";
         columns_[excluded_prefix_len_index_] = "excluded_prefix_len";
+
+        static_assert(6 < RESERVATION_COLUMNS, "6 < RESERVATION_COLUMNS");.
     }
 
     /// @brief Returns last fetched reservation id.
index a9450777ea3f6574a9c381fb0ae1337aacebbccd..5ddc7de7e063a57754c154cacfb28af8fb1bf59a 100644 (file)
@@ -181,9 +181,6 @@ public:
             // Add the error flags
             setErrorIndicators(bind_, error_, LOG_COLUMNS);
 
-            // .. and check that we have the numbers correct at compile time.
-            static_assert(1 < LOG_COLUMNS, "1 < LOG_COLUMNS");
-
         } catch (const std::exception& ex) {
             isc_throw(DbOperationError,
                       "Could not create bind array from log: '"
index 4d4d06038b4e5a699fe791f4aa768c530f6a9fdf..f9838ffdf5d247b5fbfa7a63accf48e4077b3ceb 100755 (executable)
@@ -2,55 +2,96 @@
 
 set -eu
 
-# run unittests
-# ./meson.sh test -C build --setup valgrind_gen_suppressions
-for i in $(find build | grep "valgrind-supp-" | grep -v "txt\.supp")
-do
-       found=$(grep -c "<suppression>" "$i")
-       if [ "$found" -eq 0 ]
-       then
-               continue
-       fi
-       # remove useless data
-       xmlstarlet sel -t -v "/valgrindoutput/error/suppression/rawtext" "$i" | grep "\S" | sed 's/&lt;/</g; s/&gt;/>/g; s/&amp;/\&/g; s/&quot;/"/g; s/&apos;/'"'"'/g' > "$i-txt.supp"
-       # extract the binary path and name
-       found_in_path=$(xmlstarlet sel -t -v "/valgrindoutput/args/argv/exe" "$i" | sed "s|.*src|src|")
-       # insert a comment with the binary path and name
-       sed -i "s|<insert_a_suppression_name_here>|<insert_a_suppression_name_here>\n   # detected in $found_in_path|g" "$i-txt.supp"
-       # split the file
-       csplit -s -z -f "$i-txt.supp-part." "$i-txt.supp" '/{/' '{*}'
+# Print usage.
+print_usage() {
+  printf \
+'Usage: %s {{options}}
+Options:
+  [-d|--debug]                 enable debug mode, showing every executed command
+  [-k|--keep]                  do not remove meson generated files
+  [-h|--help]                  print usage (this text)
+' \
+    "$(basename "${0}")"
+}
+
+# Parse parameters.
+while test ${#} -gt 0; do
+  case "${1}" in
+    # [-d|--debug]             enable debug mode, showing every executed command
+    '-d'|'--debug') set -vx ;;
+
+    # [-h|--help]              print usage (this text).
+    '-h'|'--help') print_usage; exit 0 ;;
+
+    # [-k|--keep]              do not remove meson generated files
+    '-k'|'--keep') keep_files=true ;;
+
+    # Unrecognized argument
+    *)
+    printf "ERROR: Unrecognized argument '%s'\\n" "${1}" 1>&2; print_usage; exit 1 ;;
+  esac; shift
 done
-echo "" > build/valgrind_suppression.supp
-for i in $(find build/ | grep "txt\.supp-part\.")
-do
-       # compute md5sum
-       label=$(grep -v "insert_a_suppression_name_here" "$i" | grep -v "# detected in " | md5sum | cut -d " " -f 1)
-       # update label 
-       sed -i "s/<insert_a_suppression_name_here>/valgrind_hash_$label/g" "$i"
-       # check if hash is present
-       match=$(grep -c "$label" build/valgrind_suppression.supp)
-       if [ "$match" -eq 0 ]
-       then
-               # include entire content if hash not present
-               cat "$i" >> build/valgrind_suppression.supp
-       else
-               # extract the binary path and name
-               found_in_path=$(grep " # detected in " "$i")
-               # update comment with binary path and name if hash not present
-               sed -i "s|valgrind_hash_$label|valgrind_hash_$label\n$found_in_path|g" build/valgrind_suppression.supp
-       fi
+
+# Default parameters
+test -z "${keep_files+x}" && keep_files=false
+
+# Script can be called from wherever, and it changes directory to repo root.
+script_parent_dir=$(cd "$(dirname "${0}")" && pwd)
+cd "${script_parent_dir}/.."
+
+if test ! -d build; then
+    echo "Directory 'build' not found, but it was expected. Did you run 'meson setup build'?"
+    exit 1
+fi
+
+partial_suppression_files=$(find build -type f -name '*valgrind-supp-*' -and -not -name '*txt.supp*')
+if test -z "${partial_suppression_files}"; then
+    echo "No partial suppression files found. Did you run 'meson test -C build --setup valgrind_gen_suppressions'?"
+    exit 1
+fi
+
+for i in ${partial_suppression_files}; do
+    found=$(grep -c "<suppression>" "$i" || true)
+    if [ "$found" -eq 0 ]; then
+        continue
+    fi
+    # remove useless data
+    xmlstarlet sel -t -v "/valgrindoutput/error/suppression/rawtext" "$i" | grep "\S" | sed 's/&lt;/</g; s/&gt;/>/g; s/&amp;/\&/g; s/&quot;/"/g; s/&apos;/'"'"'/g' >"$i-txt.supp"
+    # extract the binary path and name
+    found_in_path=$(xmlstarlet sel -t -v "/valgrindoutput/args/argv/exe" "$i" | sed "s|.*src|src|")
+    # insert a comment with the binary path and name
+    sed -i "s|<insert_a_suppression_name_here>|<insert_a_suppression_name_here>\n   # detected in $found_in_path|g" "$i-txt.supp"
+    # split the file
+    csplit -s -z -f "$i-txt.supp-part." "$i-txt.supp" '/{/' '{*}'
+done
+
+echo "" >build/valgrind_suppression.supp
+for i in $(find build -type f -name '*txt.supp-part.*'); do
+    # compute md5sum
+    label=$(grep -v "insert_a_suppression_name_here" "$i" | grep -v "# detected in " | md5sum | cut -d " " -f 1)
+    # update label
+    sed -i "s/<insert_a_suppression_name_here>/valgrind_hash_$label/g" "$i"
+    # check if hash is present
+    match=$(grep -c "$label" build/valgrind_suppression.supp || true)
+    if [ "$match" -eq 0 ]; then
+        # include entire content if hash not present
+        cat "$i" >>build/valgrind_suppression.supp
+    else
+        # extract the binary path and name
+        found_in_path=$(grep " # detected in " "$i" || true)
+        # update comment with binary path and name if hash not present
+        sed -i "s|valgrind_hash_$label|valgrind_hash_$label\n$found_in_path|g" build/valgrind_suppression.supp
+    fi
 done
 csplit -s -z -f build/valgrind_suppression.supp.part. build/valgrind_suppression.supp '/{/' '{*}'
-for i in $(find build/ | grep "valgrind_suppression\.supp\.part\.")
-do
-       name=$(grep "valgrind_hash_" "$i" | tr -d " ")
-       if [ -z "$name" ]
-       then
-               continue
-       fi
-       mv "$i" "build/$name"
+for i in $(find build -type f -name '*valgrind_suppression.supp.part.*'); do
+    name=$(grep "valgrind_hash_" "$i" | tr -d " ")
+    if [ -z "$name" ]; then
+        continue
+    fi
+    mv "$i" "build/$name"
 done
-cat << EOF > build/valgrind_suppression.supp
+cat <<EOF >build/valgrind_suppression.supp
 # Valgrind suppressions file. Place permanent suppressions that we never
 # want to reconsider again into this file. For temporary suppressions
 # that we want to revisit in the future, use
@@ -63,12 +104,13 @@ cat << EOF > build/valgrind_suppression.supp
 # In case you want to make sense of the following symbols, demangle them
 # with a command like: c++filt < valgrind-suppressions
 EOF
-for i in $(find build/ | grep "valgrind_hash_" | sort -V)
-do
-       cat "$i" >> build/valgrind_suppression.supp
+for i in $(find build -type f -name '*valgrind_hash_*' | sort -V); do
+    cat "$i" >>build/valgrind_suppression.supp
 done
 # remove files
-find build/ | grep "valgrind_hash_" | xargs rm -rf
-find build/ | grep "txt\.supp-part\." | xargs rm -rf
-find build/ | grep "valgrind-supp-" | xargs rm -rf
+find build -type f -name '*valgrind_hash_*' -exec rm -rf {} ';'
+find build -type f -name '*txt.supp-part.*' -exec rm -rf {} ';'
+if [ $keep_files -eq false ]; then
+    find build -type f -name '*valgrind-supp-*' -exec rm -rf {} ';'
+fi
 mv build/valgrind_suppression.supp src/valgrind.supp