diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..2af60131 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,47 @@ +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: '41 4 * * 2' + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + runs-on: 'ubuntu-20.04' + strategy: + fail-fast: false + matrix: + include: + - language: c-cpp + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + + - name: Install packages + run: | + sudo apt update + sudo apt-get install -y \ + autoconf \ + build-essential \ + gperf \ + check \ + help2man \ + + - name: Build + run: | + ./autogen.sh + make + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/src/naemon/macros.c b/src/naemon/macros.c index 587a75a4..abcd5ece 100644 --- a/src/naemon/macros.c +++ b/src/naemon/macros.c @@ -76,7 +76,7 @@ static const struct macro_key_code *find_macro_key(const char *name) struct macro_key_code *key; high = MACRO_X_COUNT; - while (high - low > 0) { + while (high > low) { unsigned int mid = low + ((high - low) / 2); key = ¯o_keys[mid]; value = strcmp(name, key->name); diff --git a/src/naemon/sretention.c b/src/naemon/sretention.c index d99938c7..3d3d3d69 100644 --- a/src/naemon/sretention.c +++ b/src/naemon/sretention.c @@ -24,7 +24,7 @@ void save_state_information_eventhandler(struct nm_event_execution_properties *e int status; if (evprop->execution_type == EVENT_EXEC_NORMAL) { - schedule_event(retention_update_interval * interval_length, save_state_information_eventhandler, evprop->user_data); + schedule_event((time_t)retention_update_interval * interval_length, save_state_information_eventhandler, evprop->user_data); status = save_state_information(TRUE); @@ -44,7 +44,7 @@ int initialize_retention_data() /* add a retention data save event if needed */ if (retain_state_information == TRUE && retention_update_interval > 0) - schedule_event(retention_update_interval * interval_length, save_state_information_eventhandler, NULL); + schedule_event((time_t)retention_update_interval * interval_length, save_state_information_eventhandler, NULL); return xrddefault_initialize_retention_data(); } diff --git a/src/naemon/utils.c b/src/naemon/utils.c index 1c101f44..2571fb67 100644 --- a/src/naemon/utils.c +++ b/src/naemon/utils.c @@ -875,11 +875,11 @@ int generate_check_stats(void) /* determine value by weighting this/last buckets... */ /* if this is the current bucket, use its full value + weighted % of last bucket */ if (x == 0) { - bucket_value = (int)(this_bucket_value + floor(last_bucket_value * last_bucket_weight)); + bucket_value = (int)(this_bucket_value + floor((double)last_bucket_value * last_bucket_weight)); } /* otherwise use weighted % of this and last bucket */ else { - bucket_value = (int)(ceil(this_bucket_value * this_bucket_weight) + floor(last_bucket_value * last_bucket_weight)); + bucket_value = (int)(ceil((double)this_bucket_value * this_bucket_weight) + floor((double)last_bucket_value * (double)last_bucket_weight)); } /* 1 minute stats */