From 3b5ffda9ab5ce19d4e05081d1cff698bb4d847c1 Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Wed, 12 Feb 2025 09:53:16 -0600 Subject: [PATCH 1/7] fixed remaining codeql issues --- src/H5LS.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/H5LS.c b/src/H5LS.c index 2e7f43d..4a16966 100644 --- a/src/H5LS.c +++ b/src/H5LS.c @@ -187,7 +187,12 @@ herr_t readLSConf(char *fname, cache_storage_t *LS) { if (get_replacement_policy_from_str(mac) > 0) LS->replacement_policy = get_replacement_policy_from_str(mac); } else { - LOG_WARN(-1, "Unknown configuration setup:", ip); + char temp_ip[256]; + strncpy(temp_ip, ip, sizeof(temp_ip) - 1); + temp_ip[sizeof(temp_ip) - 1] = '\0'; + snprintf(error_msg, ERROR_MSG_SIZE, "Unknown configuration setup: %s", + temp_ip); + LOG_WARN(-1, "%s", error_msg); } } if (LS->mspace_total < LS->write_buffer_size) { @@ -202,7 +207,7 @@ herr_t readLSConf(char *fname, cache_storage_t *LS) { struct stat sb; if (strcmp(LS->type, "GPU") == 0 || strcmp(LS->type, "MEMORY") == 0 || (stat(LS->path, &sb) == 0 && S_ISDIR(sb.st_mode))) { - return 0; + return SUCCEED; } else { int ret = snprintf(error_msg, ERROR_MSG_SIZE, "H5LSset: path %s does not exist\n", LS->path); @@ -212,6 +217,7 @@ herr_t readLSConf(char *fname, cache_storage_t *LS) { LOG_ERROR(-1, "%s", error_msg); MPI_Abort(MPI_COMM_WORLD, 112); } + return SUCCEED; } /*------------------------------------------------------------------------- @@ -295,7 +301,7 @@ herr_t H5LSset(cache_storage_t *LS, char *type, char *path, struct stat sb; if (strcmp(type, "GPU") == 0 || strcmp(type, "MEMORY") == 0 || (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode))) { - return 0; + return SUCCEED; } else { LOG_ERROR(-1, "ERROR in name space for cache storage: %s does " @@ -303,6 +309,7 @@ herr_t H5LSset(cache_storage_t *LS, char *type, char *path, path); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); } + return SUCCEED; } /* end H5LSset */ /*------------------------------------------------------------------------- @@ -451,7 +458,7 @@ herr_t H5LSclaim_space(cache_storage_t *LS, hsize_t size, cache_claim_t type, } } - return 0; + return SUCCEED; } /*------------------------------------------------------------------------- @@ -490,7 +497,7 @@ herr_t H5LSremove_cache(cache_storage_t *LS, cache_t *cache) { #ifndef NDEBUG LOG_INFO(-1, "H5LSremove_space DONE"); #endif - return 0; + return SUCCEED; } /* end H5LSremove_cache() */ /*------------------------------------------------------------------------- From 2fded6a363b9557422519f90fe77e78494a37d4a Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Thu, 13 Feb 2025 11:59:07 -0600 Subject: [PATCH 2/7] simplified to snprintf --- src/H5LS.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/H5LS.c b/src/H5LS.c index 4a16966..d727c5c 100644 --- a/src/H5LS.c +++ b/src/H5LS.c @@ -187,11 +187,7 @@ herr_t readLSConf(char *fname, cache_storage_t *LS) { if (get_replacement_policy_from_str(mac) > 0) LS->replacement_policy = get_replacement_policy_from_str(mac); } else { - char temp_ip[256]; - strncpy(temp_ip, ip, sizeof(temp_ip) - 1); - temp_ip[sizeof(temp_ip) - 1] = '\0'; - snprintf(error_msg, ERROR_MSG_SIZE, "Unknown configuration setup: %s", - temp_ip); + snprintf(error_msg, ERROR_MSG_SIZE, "Unknown configuration setup: %s", ip); LOG_WARN(-1, "%s", error_msg); } } From a27eac8122e39200eb7d411ba86ba664f475093f Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Thu, 13 Feb 2025 12:30:48 -0600 Subject: [PATCH 3/7] updated clang-format action, is not committing the changes --- .github/workflows/clang-format-check.yml | 6 ++++-- .github/workflows/clang-format-fix.yml | 26 +++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml index 30ec4de..79266e9 100644 --- a/.github/workflows/clang-format-check.yml +++ b/.github/workflows/clang-format-check.yml @@ -1,15 +1,17 @@ name: clang-format Check on: pull_request: + jobs: formatting-check: name: Formatting Check runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, 'skip-ci')" steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.7 + - name: Run clang-format style check for C programs. - uses: DoozyX/clang-format-lint-action@v0.14 + uses: DoozyX/clang-format-lint-action@v0.18.2 with: source: '.' extensions: 'c,h,cpp,hpp' diff --git a/.github/workflows/clang-format-fix.yml b/.github/workflows/clang-format-fix.yml index be7f1e9..70427ab 100644 --- a/.github/workflows/clang-format-fix.yml +++ b/.github/workflows/clang-format-fix.yml @@ -1,16 +1,32 @@ -name: clang-format Check +# NOTE: This action requires write permissions to be set in your GitHub +# repo/fork for it to be able to commit changes. +# +# This is currently enabled via: +# +# settings > Actions > General > Workflow permissions +# +# which you will need to set to "Read and write permissions" +# +name: clang-format Commit Changes on: workflow_dispatch: push: + +permissions: + contents: read + jobs: formatting-check: - name: Formatting Check + name: Commit Format Changes runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, 'skip-ci')" + permissions: + contents: write # In order to allow EndBug/add-and-commit to commit changes steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.7 + - name: Run clang-format style check for C programs. - uses: DoozyX/clang-format-lint-action@v0.14 + uses: DoozyX/clang-format-lint-action@v0.18.2 with: source: '.' extensions: 'c,h,cpp,hpp' @@ -18,7 +34,7 @@ jobs: inplace: True style: file # exclude: './config ' - - uses: EndBug/add-and-commit@v7 + - uses: EndBug/add-and-commit@v9.1.3 with: author_name: github-actions author_email: github-actions[bot]@users.noreply.github.com From fe019eb07a3285a2c7a99186b7585d2228a33204 Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Thu, 13 Feb 2025 18:02:21 -0600 Subject: [PATCH 4/7] test clang-format --- .github/workflows/clang-format-fix.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang-format-fix.yml b/.github/workflows/clang-format-fix.yml index 70427ab..64439af 100644 --- a/.github/workflows/clang-format-fix.yml +++ b/.github/workflows/clang-format-fix.yml @@ -34,8 +34,9 @@ jobs: inplace: True style: file # exclude: './config ' - - uses: EndBug/add-and-commit@v9.1.3 + + - uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 #v9.1.4 with: author_name: github-actions - author_email: github-actions[bot]@users.noreply.github.com + author_email: 41898282+github-actions[bot]@users.noreply.github.com message: 'Committing clang-format changes' From 541623ee07657aeec1547bc14064e77c088deea9 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 14 Feb 2025 00:02:40 +0000 Subject: [PATCH 5/7] Committing clang-format changes --- src/H5LS.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/H5LS.c b/src/H5LS.c index d727c5c..bc0cf41 100644 --- a/src/H5LS.c +++ b/src/H5LS.c @@ -187,7 +187,8 @@ herr_t readLSConf(char *fname, cache_storage_t *LS) { if (get_replacement_policy_from_str(mac) > 0) LS->replacement_policy = get_replacement_policy_from_str(mac); } else { - snprintf(error_msg, ERROR_MSG_SIZE, "Unknown configuration setup: %s", ip); + snprintf(error_msg, ERROR_MSG_SIZE, "Unknown configuration setup: %s", + ip); LOG_WARN(-1, "%s", error_msg); } } From 2c8e452d9a54eb6e9f2417bc6aef72ee5086dcec Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Fri, 14 Feb 2025 10:22:36 -0600 Subject: [PATCH 6/7] clang-format update --- .github/workflows/clang-format-fix.yml | 4 ++-- src/H5LS.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/clang-format-fix.yml b/.github/workflows/clang-format-fix.yml index 64439af..e0a8d29 100644 --- a/.github/workflows/clang-format-fix.yml +++ b/.github/workflows/clang-format-fix.yml @@ -35,8 +35,8 @@ jobs: style: file # exclude: './config ' - - uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 #v9.1.4 + - uses: EndBug/add-and-commit@v9.1.3 with: author_name: github-actions - author_email: 41898282+github-actions[bot]@users.noreply.github.com + author_email: github-actions[bot]@users.noreply.github.com message: 'Committing clang-format changes' diff --git a/src/H5LS.c b/src/H5LS.c index bc0cf41..d727c5c 100644 --- a/src/H5LS.c +++ b/src/H5LS.c @@ -187,8 +187,7 @@ herr_t readLSConf(char *fname, cache_storage_t *LS) { if (get_replacement_policy_from_str(mac) > 0) LS->replacement_policy = get_replacement_policy_from_str(mac); } else { - snprintf(error_msg, ERROR_MSG_SIZE, "Unknown configuration setup: %s", - ip); + snprintf(error_msg, ERROR_MSG_SIZE, "Unknown configuration setup: %s", ip); LOG_WARN(-1, "%s", error_msg); } } From d7e695ed15424a3c8f249ee005224e395c5865af Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Fri, 14 Feb 2025 10:25:58 -0600 Subject: [PATCH 7/7] format update --- src/H5LS.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/H5LS.c b/src/H5LS.c index d727c5c..bc0cf41 100644 --- a/src/H5LS.c +++ b/src/H5LS.c @@ -187,7 +187,8 @@ herr_t readLSConf(char *fname, cache_storage_t *LS) { if (get_replacement_policy_from_str(mac) > 0) LS->replacement_policy = get_replacement_policy_from_str(mac); } else { - snprintf(error_msg, ERROR_MSG_SIZE, "Unknown configuration setup: %s", ip); + snprintf(error_msg, ERROR_MSG_SIZE, "Unknown configuration setup: %s", + ip); LOG_WARN(-1, "%s", error_msg); } }