Skip to content

Commit dece779

Browse files
committed
net: ocpp: Fix multiple issues detected by clang
Fix multiple warnings detected by clang: * implicit conversions back and forth from enumeration type 'enum ocpp_notify_reason' to 'enum ocpp_pdu_msg' in ocpp_internal_handler() * label followed by a declarations * variable declared after one switch case and used in another * mapping a int to uint and later using it in < 0 comparisons and with negative values Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent 1747bd7 commit dece779

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

subsys/net/lib/ocpp/ocpp.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ static void ocpp_internal_handler(void *p1, void *p2, void *p3)
239239
break;
240240

241241
case PDU_METER_VALUES:
242+
{
242243
union ocpp_io_value io;
243244
sys_snode_t *node;
244245
struct ocpp_session *lsh;
@@ -270,7 +271,7 @@ static void ocpp_internal_handler(void *p1, void *p2, void *p3)
270271
}
271272
k_mutex_unlock(&ctx->ilock);
272273
break;
273-
274+
}
274275
case PDU_HEARTBEAT:
275276
ocpp_heartbeat(sh);
276277
/* adjust local time with cs time ! */
@@ -286,18 +287,15 @@ static void ocpp_internal_handler(void *p1, void *p2, void *p3)
286287
break;
287288

288289
case PDU_REMOTE_START_TRANSACTION:
289-
msg.msgtype = OCPP_USR_START_CHARGING;
290-
ctx->cb(msg.msgtype, &msg.usr, ctx->user_data);
290+
ctx->cb(OCPP_USR_START_CHARGING, &msg.usr, ctx->user_data);
291291
break;
292292

293293
case PDU_REMOTE_STOP_TRANSACTION:
294-
msg.msgtype = OCPP_USR_STOP_CHARGING;
295-
ctx->cb(msg.msgtype, &msg.usr, ctx->user_data);
294+
ctx->cb(OCPP_USR_STOP_CHARGING, &msg.usr, ctx->user_data);
296295
break;
297296

298297
case PDU_UNLOCK_CONNECTOR:
299-
msg.msgtype = OCPP_USR_UNLOCK_CONNECTOR;
300-
ctx->cb(msg.msgtype, &msg.usr, ctx->user_data);
298+
ctx->cb(OCPP_USR_UNLOCK_CONNECTOR, &msg.usr, ctx->user_data);
301299
break;
302300

303301
default:
@@ -345,6 +343,7 @@ static int ocpp_process_server_msg(struct ocpp_info *ctx)
345343
char skey[CISTR50];
346344

347345
case PDU_BOOTNOTIFICATION:
346+
{
348347
struct boot_notif binfo;
349348

350349
ret = fn(ui->recv_buf, &binfo);
@@ -353,9 +352,10 @@ static int ocpp_process_server_msg(struct ocpp_info *ctx)
353352
ctx->hb_sec = binfo.interval;
354353
}
355354
break;
356-
355+
}
357356
case PDU_AUTHORIZE:
358357
case PDU_STOP_TRANSACTION:
358+
{
359359
struct ocpp_idtag_info idinfo = {0};
360360

361361
if (sh == NULL) {
@@ -367,8 +367,10 @@ static int ocpp_process_server_msg(struct ocpp_info *ctx)
367367
sh->resp_status = idinfo.auth_status;
368368
}
369369
break;
370-
370+
}
371371
case PDU_START_TRANSACTION:
372+
{
373+
struct ocpp_idtag_info idinfo = {0};
372374
if (sh == NULL) {
373375
break;
374376
}
@@ -379,7 +381,7 @@ static int ocpp_process_server_msg(struct ocpp_info *ctx)
379381
sh->resp_status = idinfo.auth_status;
380382
}
381383
break;
382-
384+
}
383385
case PDU_GET_CONFIGURATION:
384386
memset(skey, 0, sizeof(skey));
385387

@@ -402,6 +404,7 @@ static int ocpp_process_server_msg(struct ocpp_info *ctx)
402404
break;
403405

404406
case PDU_CHANGE_CONFIGURATION:
407+
{
405408
char sval[CISTR500] = {0};
406409

407410
memset(skey, 0, sizeof(skey));
@@ -412,7 +415,7 @@ static int ocpp_process_server_msg(struct ocpp_info *ctx)
412415

413416
ocpp_change_configuration(skey, ctx, sval, uid);
414417
break;
415-
418+
}
416419
case PDU_HEARTBEAT:
417420
/* todo : sync time */
418421
break;
@@ -471,7 +474,7 @@ static void ocpp_wsreader(void *p1, void *p2, void *p3)
471474
struct ocpp_info *ctx = p1;
472475
struct ocpp_upstream_info *ui = &ctx->ui;
473476
struct zsock_pollfd tcpfd;
474-
uint8_t ret;
477+
int ret;
475478
uint8_t retry_cnt = 0;
476479

477480
ctx->is_cs_offline = true;

0 commit comments

Comments
 (0)