pull/486/merge
Artem Gavrilov 2025-06-20 08:36:13 +01:00 committed by GitHub
commit e662a2eae0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 14 deletions

View File

@ -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

6
guc.c
View File

@ -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
@ -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));
}

View File

@ -275,10 +275,10 @@ static void pgsm_lock_release(pgsmSharedState *pgsm);
/*
* Module load callback
*
*/
/* cppcheck-suppress unusedFunction */
void
_PG_init(void)
_PG_init(void) /* cppcheck-suppress unusedFunction */
{
int rc;
@ -1383,14 +1383,12 @@ pg_get_backend_status(void)
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();
if (!beentry)
snprintf(name, buff_size, "%s", "unknown");
@ -1569,7 +1567,6 @@ pgsm_update_entry(pgsmEntry *entry,
/* 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();
/*
@ -1581,7 +1578,8 @@ pgsm_update_entry(pgsmEntry *entry,
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 */
@ -1710,12 +1708,14 @@ pgsm_store_error(const char *query, ErrorData *edata)
{
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);
@ -3973,7 +3973,6 @@ get_histogram_timings(PG_FUNCTION_ARGS)
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,
@ -3982,7 +3981,8 @@ extract_query_comments(const char *query, char *comments, size_t max_len)
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;
@ -4016,6 +4016,7 @@ extract_query_comments(const char *query, char *comments, size_t max_len)
static uint64
get_query_id(JumbleState *jstate, Query *query)
{
/* cppcheck-suppress-begin nullPointerRedundantCheck symbolName=jstate */
uint64 queryid;
/* Set up workspace for query jumbling */
@ -4030,6 +4031,7 @@ get_query_id(JumbleState *jstate, Query *query)
JumbleQuery(jstate, query);
queryid = pgsm_hash_string((const char *) jstate->jumble, jstate->jumble_len);
return queryid;
/* cppcheck-suppress-end nullPointerRedundantCheck symbolName=jstate */
}
#endif