all: clang-tidy updates

This commit is contained in:
Markus F.X.J. Oberhumer 2023-07-08 09:59:41 +02:00
parent d7754a97c7
commit 5edfda46e5
9 changed files with 52 additions and 15 deletions

View File

@ -1,6 +1,6 @@
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
---
Checks: 'bugprone-exception-*,clang-analyzer-*,-clang-analyzer-optin.performance.Padding,-clang-analyzer-security.insecureAPI.strcpy,clang-diagnostics-*'
Checks: 'bugprone-exception-*,clang-analyzer-*,-clang-analyzer-optin.performance.Padding,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-security.insecureAPI.strcpy,clang-diagnostics-*'
FormatStyle: file
HeaderFilterRegex: '.*'
...

View File

@ -1,12 +1,12 @@
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
name: 'Static Analyzer - clang scan-build'
name: 'Static Analyzer - clang-analyzer'
on:
schedule: [cron: '20 5 * * 3'] # run weekly Wednesday 05:20 UTC
workflow_dispatch:
jobs:
job-analyze-clang: # uses cmake + make
job-analyze-clang-analyzer: # uses cmake + make
strategy:
fail-fast: false
matrix: {container: ['alpine:3.16','alpine:3.17','alpine:3.18','alpine:edge','i386/alpine:edge']}
@ -15,7 +15,7 @@ jobs:
container: ${{ matrix.container }}
steps:
- name: ${{ format('Install packages {0}', matrix.container) }}
run: 'apk update && apk upgrade && apk add bash clang clang-analyzer cmake g++ git make'
run: 'apk update && apk upgrade && apk add clang clang-analyzer cmake g++ git make'
- name: ${{ format('Check out UPX {0} source code', github.ref_name) }}
run: |
git clone --branch "$GITHUB_REF_NAME" --depth 1 https://github.com/upx/upx
@ -23,4 +23,5 @@ jobs:
- name: 'Perform clang scan-build Analysis Debug'
run: 'make -C upx build/extra/scan-build/debug'
- name: 'Perform clang scan-build Analysis Release'
if: success() || failure() # run this step even if the previous step failed
run: 'make -C upx build/extra/scan-build/release'

View File

@ -0,0 +1,31 @@
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
name: 'Static Analyzer - clang-tidy'
on:
schedule: [cron: '30 5 * * 3'] # run weekly Wednesday 05:30 UTC
workflow_dispatch:
jobs:
job-analyze-clang-tidy: # uses cmake + make
strategy:
fail-fast: false
matrix: {container: ['alpine:edge','i386/alpine:edge']}
name: ${{ format('Analyze clang-tidy {0}', matrix.container) }}
runs-on: ubuntu-latest
container: ${{ matrix.container }}
steps:
- name: ${{ format('Install packages {0}', matrix.container) }}
run: 'apk update && apk upgrade && apk add clang clang-extra-tools cmake g++ git make'
- name: ${{ format('Check out UPX {0} source code', github.ref_name) }}
run: |
git clone --branch "$GITHUB_REF_NAME" --depth 1 https://github.com/upx/upx
git -C upx submodule update --init
- name: 'Perform clang-tidy Analysis Debug'
run: |
make -C upx build/extra/clang/debug
run-clang-tidy -p upx/build/extra/clang/debug
- name: 'Perform clang-tidy Analysis Release'
if: success() || failure() # run this step even if the previous step failed
run: |
make -C upx build/extra/clang/release
run-clang-tidy -p upx/build/extra/clang/release

View File

@ -26,9 +26,10 @@
*/
#include "conf.h"
#include "packmast.h"
#include "packer.h"
#include "compress/compress.h" // upx_ucl_version_string()
// for list_all_packers():
#include "packer.h"
#include "packmast.h" // PackMaster::visitAllPackers
/*************************************************************************
// header
@ -89,7 +90,7 @@ void show_usage(void) {
}
/*************************************************************************
// util
// list_all_packers()
**************************************************************************/
namespace {
@ -121,8 +122,9 @@ struct PackerNames {
return strcmp(((const Entry *) a)->sname, ((const Entry *) b)->sname);
}
};
} // namespace
static void show_all_packers(FILE *f, int verbose) {
static void list_all_packers(FILE *f, int verbose) {
Options o;
o.reset();
PackerNames pn;
@ -152,7 +154,6 @@ static void show_all_packers(FILE *f, int verbose) {
if (verbose <= 0 && pn.names_count)
con_fprintf(f, "\n");
}
} // namespace
/*************************************************************************
// help
@ -291,7 +292,7 @@ void show_help(int verbose) {
fg = con_fg(f, FG_YELLOW);
con_fprintf(f, "\nThis version supports:\n");
fg = con_fg(f, fg);
show_all_packers(f, verbose);
list_all_packers(f, verbose);
} else {
con_fprintf(f, "\nType '%s --help' for more detailed help.\n", progname);
}

View File

@ -60,12 +60,14 @@ static constexpr unsigned MAX_ELF_HDR_64 = 1024;
static unsigned const EF_ARM_EABI_VER4 = 0x04000000;
static unsigned const EF_ARM_EABI_VER5 = 0x05000000;
unsigned char PackLinuxElf::o_shstrtab[] = { \
/*static*/ const unsigned char PackLinuxElf::o_shstrtab[] = { \
/*start*/ '\0',
/*offset 1*/ '.','n','o','t','e','.','g','n','u','.','b','u','i','l','d','-','i','d','\0',
/*offset 20*/ '.','s','h','s','t','r','t','a','b','\0'
};
// NOLINTBEGIN(clang-analyzer-*)
static unsigned
umin(unsigned a, unsigned b)
{
@ -8487,4 +8489,6 @@ void PackLinuxElf::unpack(OutputFile * /*fo*/)
throwCantUnpack("internal error");
}
// NOLINTEND(clang-analyzer-*)
/* vim:set ts=4 sw=4 et: */

View File

@ -127,7 +127,7 @@ protected:
MemBuffer note_body; // concatenated contents of PT_NOTEs, if any
unsigned note_size; // total size of PT_NOTEs
int o_elf_shnum; // num output Shdrs
static unsigned char o_shstrtab[];
static const unsigned char o_shstrtab[];
};
class PackLinuxElf32 : public PackLinuxElf

View File

@ -79,6 +79,7 @@ struct UiPacker::State {
#endif
};
// static
unsigned UiPacker::total_files = 0;
unsigned UiPacker::total_files_done = 0;
upx_uint64_t UiPacker::total_c_len = 0;
@ -155,7 +156,7 @@ static const char *mkline(upx_uint64_t fu_len, upx_uint64_t fc_len, upx_uint64_t
//
**************************************************************************/
UiPacker::UiPacker(const Packer *p_) : ui_pass(0), ui_total_passes(0), p(p_), s(nullptr) {
UiPacker::UiPacker(const Packer *p_) : p(p_) {
static upx_std_once_flag init_done;
upx_std_call_once(init_done, init_global_constants);

View File

@ -84,7 +84,7 @@ public:
protected:
virtual void printInfo(int nl = 0);
const Packer *p = nullptr;
const Packer *const p;
// callback
upx_callback_t cb = {};

View File

@ -33,7 +33,6 @@
#include "conf.h"
#include "file.h"
#include "packmast.h"
#include "packer.h"
#include "ui.h"
#if (ACC_OS_DOS32) && defined(__DJGPP__)