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

PG-1101 Change cppcheck parameters #486

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
working-directory: src/pg_stat_monitor
run: |
set -x
cppcheck --enable=all --inline-suppr --template='{file}:{line},{severity},{id},{message}' --error-exitcode=1 --suppress=missingIncludeSystem --suppress=missingInclude --suppress=unmatchedSuppression:pg_stat_monitor.c --check-config .
cppcheck --enable=all --inline-suppr --std=c99 --check-level=exhaustive --error-exitcode=1 --suppress=missingIncludeSystem --suppress=missingInclude .

format:
name: Format
Expand Down
6 changes: 4 additions & 2 deletions guc.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ init_guc(void)

/* Maximum value must be greater or equal to minimum + 1.0 */
static bool
check_histogram_min(double *newval, void **extra, GucSource source)
check_histogram_min(double *newval, void **extra, GucSource source) /* cppcheck-suppress
* constParameterCallback */
{
/*
* During module initialization PGSM_HISTOGRAM_MIN is initialized before
Expand All @@ -303,7 +304,8 @@ check_histogram_min(double *newval, void **extra, GucSource source)
}

static bool
check_histogram_max(double *newval, void **extra, GucSource source)
check_histogram_max(double *newval, void **extra, GucSource source) /* cppcheck-suppress
* constParameterCallback */
{
return (*newval >= (pgsm_histogram_min + 1.0));
}
Expand Down
24 changes: 13 additions & 11 deletions pg_stat_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@

/*
* Module load callback
*
*/
/* cppcheck-suppress unusedFunction */
void
_PG_init(void)
_PG_init(void) /* cppcheck-suppress unusedFunction */
{
int rc;

Expand Down Expand Up @@ -1369,14 +1369,12 @@
static int
pg_get_application_name(char *name, int buff_size)
{
PgBackendStatus *beentry;

/* Try to read application name from GUC directly */
if (application_name && *application_name)
snprintf(name, buff_size, "%s", application_name);
else
{
beentry = pg_get_backend_status();
PgBackendStatus *beentry = pg_get_backend_status();

Check warning on line 1377 in pg_stat_monitor.c

View check run for this annotation

Codecov / codecov/patch

pg_stat_monitor.c#L1377

Added line #L1377 was not covered by tests

if (!beentry)
snprintf(name, buff_size, "%s", "unknown");
Expand Down Expand Up @@ -1555,7 +1553,6 @@
/* If we have a parent query, store it in the raw dsa area */
if (parent_query_len > 0)
{
char *qry_buff;
dsa_area *query_dsa_area = get_dsa_area_for_query_text();

/*
Expand All @@ -1567,7 +1564,8 @@

if (DsaPointerIsValid(qry))
{
qry_buff = dsa_get_address(query_dsa_area, qry);
char *qry_buff = dsa_get_address(query_dsa_area, qry);

memcpy(qry_buff, nested_query_txts[nesting_level - 1], parent_query_len);
qry_buff[parent_query_len] = 0;
/* store the dsa pointer for parent query text */
Expand Down Expand Up @@ -1696,12 +1694,14 @@
{
pgsmEntry *entry;
uint64 queryid = 0;
int len = strlen(query);
int len;

if (!query || len == 0)
if (query == NULL)
return;

len = strlen(query);
if (len == 0)
return;

queryid = pgsm_hash_string(query, len);

Expand Down Expand Up @@ -3959,7 +3959,6 @@
static void
extract_query_comments(const char *query, char *comments, size_t max_len)
{
int rc;
size_t nmatch = 1;
regmatch_t pmatch;
regoff_t comment_len,
Expand All @@ -3968,7 +3967,8 @@

while (total_len < max_len)
{
rc = regexec(&preg_query_comments, s, nmatch, &pmatch, 0);
int rc = regexec(&preg_query_comments, s, nmatch, &pmatch, 0);

if (rc != 0)
break;

Expand Down Expand Up @@ -4002,6 +4002,7 @@
static uint64
get_query_id(JumbleState *jstate, Query *query)
{
/* cppcheck-suppress-begin nullPointerRedundantCheck symbolName=jstate */
uint64 queryid;

/* Set up workspace for query jumbling */
Expand All @@ -4016,5 +4017,6 @@
JumbleQuery(jstate, query);
queryid = pgsm_hash_string((const char *) jstate->jumble, jstate->jumble_len);
return queryid;
/* cppcheck-suppress-end nullPointerRedundantCheck symbolName=jstate */
}
#endif
Loading