Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable codeql scanner & fix detected defects #481

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -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}}"
2 changes: 1 addition & 1 deletion src/naemon/macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = &macro_keys[mid];
value = strcmp(name, key->name);
Expand Down
4 changes: 2 additions & 2 deletions src/naemon/sretention.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/naemon/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Loading