Skip to content

Commit a7503db

Browse files
committed
address SonarQube warnings; reformat
Signed-off-by: Hans Zandbelt <[email protected]>
1 parent 550cdf1 commit a7503db

File tree

4 files changed

+70
-31
lines changed

4 files changed

+70
-31
lines changed

src/cache/memcache.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ static int oidc_cache_memcache_post_config(server_rec *s) {
9090
apr_uint32_t smax = 0;
9191
apr_uint32_t hmax = 0;
9292
apr_uint32_t ttl = 0;
93-
;
9493

9594
if (oidc_cfg_cache_memcache_servers_get(cfg) == NULL) {
9695
oidc_serror(s, "cache type is set to \"memcache\", but no valid " OIDCMemCacheServers

src/handle/handle.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ char *oidc_response_make_sid_iss_unique(request_rec *r, const char *sid, const c
117117
int oidc_response_authorization_redirect(request_rec *r, oidc_cfg_t *c, oidc_session_t *session);
118118
int oidc_response_authorization_post(request_rec *r, oidc_cfg_t *c, oidc_session_t *session);
119119
apr_byte_t oidc_response_save_in_session(request_rec *r, oidc_cfg_t *c, oidc_session_t *session,
120-
oidc_provider_t *provider, const char *remoteUser, const char *id_token,
121-
oidc_jwt_t *id_token_jwt, const char *claims, const char *access_token,
122-
const char *access_token_type, const int expires_in,
123-
const char *refresh_token, const char *scope, const char *session_state,
124-
const char *state, const char *original_url, const char *userinfo_jwt);
120+
oidc_provider_t *provider, const char *remoteUser, const char *id_token,
121+
oidc_jwt_t *id_token_jwt, const char *claims, const char *access_token,
122+
const char *access_token_type, const int expires_in, const char *refresh_token,
123+
const char *scope, const char *session_state, const char *state,
124+
const char *original_url, const char *userinfo_jwt);
125125

126126
// revoke.c
127127
int oidc_revoke_session(request_rec *r, oidc_cfg_t *c);

src/handle/response.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ char *oidc_response_make_sid_iss_unique(request_rec *r, const char *sid, const c
220220
* store resolved information in the session
221221
*/
222222
apr_byte_t oidc_response_save_in_session(request_rec *r, oidc_cfg_t *c, oidc_session_t *session,
223-
oidc_provider_t *provider, const char *remoteUser, const char *id_token,
224-
oidc_jwt_t *id_token_jwt, const char *claims, const char *access_token,
225-
const char *access_token_type, const int expires_in,
226-
const char *refresh_token, const char *scope, const char *session_state,
227-
const char *state, const char *original_url, const char *userinfo_jwt) {
223+
oidc_provider_t *provider, const char *remoteUser, const char *id_token,
224+
oidc_jwt_t *id_token_jwt, const char *claims, const char *access_token,
225+
const char *access_token_type, const int expires_in, const char *refresh_token,
226+
const char *scope, const char *session_state, const char *state,
227+
const char *original_url, const char *userinfo_jwt) {
228228

229229
/* store the user in the session */
230230
session->remote_user = apr_pstrdup(r->pool, remoteUser);

src/metrics.c

Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static inline char *_json_int2str(apr_pool_t *pool, json_int_t n) {
256256
* check Jansson specific integer/long number overrun
257257
*/
258258
static inline int _is_overflow(server_rec *s, json_int_t cur, json_int_t add) {
259-
if ((add > OIDC_METRICS_INT_MAX - cur)) {
259+
if (add > (OIDC_METRICS_INT_MAX - cur)) {
260260
oidc_swarn(s,
261261
"reset metrics since the size (%s) of the integer value would be larger than the "
262262
"JSON/libjansson maximum "
@@ -412,8 +412,15 @@ static json_t *oidc_metrics_json_parse_s(server_rec *s, char *s_json) {
412412
*/
413413
static inline void oidc_metrics_storage_reset(server_rec *s) {
414414
char *s_json = NULL;
415-
json_t *json = NULL, *j_server = NULL, *j_entries = NULL, *j_entry = NULL, *j_val = NULL;
416-
void *i1 = NULL, *i2 = NULL, *i3 = NULL, *i4 = NULL;
415+
json_t *json = NULL;
416+
json_t *j_server = NULL;
417+
json_t *j_entries = NULL;
418+
json_t *j_entry = NULL;
419+
json_t *j_val = NULL;
420+
void *i1 = NULL;
421+
void *i2 = NULL;
422+
void *i3 = NULL;
423+
void *i4 = NULL;
417424
int i = 0;
418425

419426
/* get the global stringified JSON metrics */
@@ -611,12 +618,20 @@ static inline unsigned int _oidc_metrics_key2type(const char *key) {
611618
*/
612619
static void oidc_metrics_store(server_rec *s) {
613620
char *s_json = NULL;
614-
json_t *json = NULL, *j_server = NULL, *j_timer = NULL, *j_counters = NULL, *j_counter = NULL,
615-
*j_timings = NULL, *j_names = NULL;
616-
apr_hash_index_t *hi1 = NULL, *hi2 = NULL;
617-
const char *name = NULL, *key = NULL;
621+
json_t *json = NULL;
622+
json_t *j_server = NULL;
623+
json_t *j_timer = NULL;
624+
json_t *j_counters = NULL;
625+
json_t *j_counter = NULL;
626+
json_t *j_timings = NULL;
627+
json_t *j_names = NULL;
628+
apr_hash_index_t *hi1 = NULL;
629+
apr_hash_index_t *hi2 = NULL;
630+
const char *name = NULL;
631+
const char *key = NULL;
618632
char *p = NULL;
619-
apr_hash_t *server_hash = NULL, *counter_hash = NULL;
633+
apr_hash_t *server_hash = NULL;
634+
apr_hash_t *counter_hash = NULL;
620635
oidc_metrics_timing_t *timing = NULL;
621636

622637
if ((apr_hash_count(_oidc_metrics.counters) == 0) && (apr_hash_count(_oidc_metrics.timings) == 0))
@@ -712,7 +727,7 @@ static void oidc_metrics_store(server_rec *s) {
712727
/*
713728
* obtain the metrics flush interval from the environment variables
714729
*/
715-
static inline apr_interval_time_t _oidc_metrics_interval(server_rec *s) {
730+
static inline apr_interval_time_t _oidc_metrics_interval(void) {
716731
return apr_time_from_msec(_oidc_metrics_get_env_int(OIDC_METRICS_CACHE_STORAGE_INTERVAL_ENV_VAR,
717732
OIDC_METRICS_CACHE_STORAGE_INTERVAL_DEFAULT));
718733
}
@@ -738,7 +753,7 @@ static void *APR_THREAD_FUNC oidc_metrics_thread_run(apr_thread_t *thread, void
738753
apr_sleep(apr_time_from_msec(oidc_metric_random_int(1000)));
739754

740755
/* calculate the number of short sleep intervals */
741-
int n = _oidc_metrics_interval(s) / apr_time_from_msec(OIDC_METRICS_POLL_INTERVAL);
756+
int n = _oidc_metrics_interval() / apr_time_from_msec(OIDC_METRICS_POLL_INTERVAL);
742757

743758
/* see if we are asked to exit */
744759
while (_oidc_metrics_thread_exit == FALSE) {
@@ -1081,12 +1096,22 @@ static json_t *oidc_metrics_json_parse_r(request_rec *r, char *s_json) {
10811096
*/
10821097
static int oidc_metrics_handle_json(request_rec *r, char *s_json) {
10831098

1084-
json_t *json = NULL, *j_server = NULL, *j_timings, *j_counters, *j_timing = NULL, *j_counter = NULL;
1085-
json_t *o_json = NULL, *o_server = NULL, *o_counters = NULL, *o_counter = NULL, *o_timings = NULL,
1086-
*o_timing = NULL;
1099+
json_t *json = NULL;
1100+
json_t *j_server = NULL;
1101+
json_t *j_timings = NULL;
1102+
json_t *j_counters = NULL;
1103+
json_t *j_timing = NULL;
1104+
json_t *j_counter = NULL;
1105+
json_t *o_json = NULL;
1106+
json_t *o_server = NULL;
1107+
json_t *o_counters = NULL;
1108+
json_t *o_counter = NULL;
1109+
json_t *o_timings = NULL;
1110+
json_t *o_timing = NULL;
10871111
const char *s_server = NULL;
10881112
unsigned int type = 0;
1089-
void *i1 = NULL, *i2 = NULL;
1113+
void *i1 = NULL;
1114+
void *i2 = NULL;
10901115

10911116
/* parse the metrics string to JSON */
10921117
json = oidc_metrics_json_parse_r(r, s_json);
@@ -1180,9 +1205,18 @@ static int oidc_metrics_handle_internal(request_rec *r, char *s_json) {
11801205
*/
11811206
static int oidc_metrics_handle_status(request_rec *r, char *s_json) {
11821207
char *msg = "OK\n";
1183-
char *s_metric_param = NULL, *s_server_param = NULL, *s_name_param = NULL, *s_value_param = NULL;
1184-
json_t *json = NULL, *j_server = NULL, *j_counters = NULL, *j_counter = NULL, *j_values = NULL, *j_value = NULL;
1185-
const char *s_key = NULL, *s_name = NULL;
1208+
char *s_metric_param = NULL;
1209+
char *s_server_param = NULL;
1210+
char *s_name_param = NULL;
1211+
char *s_value_param = NULL;
1212+
json_t *json = NULL;
1213+
json_t *j_server = NULL;
1214+
json_t *j_counters = NULL;
1215+
json_t *j_counter = NULL;
1216+
json_t *j_values = NULL;
1217+
json_t *j_value = NULL;
1218+
const char *s_key = NULL;
1219+
const char *s_name = NULL;
11861220
unsigned int type = 0;
11871221
void *iter = NULL;
11881222

@@ -1290,10 +1324,16 @@ typedef struct oidc_metric_prometheus_callback_ctx_t {
12901324
*/
12911325
static int oidc_metrics_prometheus_counters(oidc_metric_prometheus_callback_ctx_t *ctx, const char *key,
12921326
json_t *value) {
1293-
const char *s_server = NULL, *s_key = NULL, *s_value = NULL, *s_start = NULL;
1294-
json_t *j_counter = NULL, *j_value = NULL;
1327+
const char *s_server = NULL;
1328+
const char *s_key = NULL;
1329+
const char *s_value = NULL;
1330+
const char *s_start = NULL;
1331+
json_t *j_counter = NULL;
1332+
json_t *j_value = NULL;
12951333
json_t *o_counter = value;
1296-
void *i1 = NULL, *i2 = NULL, *i3 = NULL;
1334+
void *i1 = NULL;
1335+
void *i2 = NULL;
1336+
void *i3 = NULL;
12971337
unsigned int type = _oidc_metrics_key2type(key);
12981338
const char *s_label =
12991339
oidc_metric_prometheus_normalize_name(ctx->pool, _oidc_metrics_counter_type2s(ctx->pool, type));

0 commit comments

Comments
 (0)