Skip to content

Commit a28925a

Browse files
seankyerkartben
authored andcommitted
net: ocpp: Fix cast warning
Fix warnings generated from casting pointers of different sizes and string literals in ocpp Signed-off-by: Sean Kyer <[email protected]>
1 parent f3a0e27 commit a28925a

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

subsys/net/lib/ocpp/key_mgmt.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ static struct ocpp_cfg_info cached_key_cfg[OCPP_CFG_END] = {
7474
FILL_KEY_TABLE(KEY_TYPE_INT, 1, CFG_MAX_ENERGYON_INVL_ID,
7575
"MaxEnergyOnInvalidId", 0),
7676
FILL_KEY_TABLE(KEY_TYPE_CSL, 1, CFG_MTR_VAL_ALGIN_DATA,
77-
"MeterValuesAlignedData", (uint32_t)"0"),
77+
"MeterValuesAlignedData", .str = "0"),
7878
FILL_KEY_TABLE(KEY_TYPE_INT, 0, CFG_MTR_VAL_ALGIN_DATA_MAXLEN,
7979
"MeterValuesAlignedDataMaxLength", 1),
8080
FILL_KEY_TABLE(KEY_TYPE_CSL, 1, CFG_MTR_VAL_SAMPLED_DATA,
81-
"MeterValuesSampledData", (uint32_t)"0"),
81+
"MeterValuesSampledData", .str = "0"),
8282
FILL_KEY_TABLE(KEY_TYPE_INT, 0, CFG_MTR_VAL_SAMPLED_DATA_MAXLEN,
8383
"MeterValuesSampledDataMaxLength", 1),
8484
FILL_KEY_TABLE(KEY_TYPE_INT, 1, CFG_MTR_VAL_SAMPLE_INTERVAL,
@@ -90,20 +90,20 @@ static struct ocpp_cfg_info cached_key_cfg[OCPP_CFG_END] = {
9090
FILL_KEY_TABLE(KEY_TYPE_INT, 1, CFG_REST_RETRIES,
9191
"ResetRetries", 0),
9292
FILL_KEY_TABLE(KEY_TYPE_CSL, 1, CFG_CONN_PHASE_ROT,
93-
"ConnectorPhaseRotation", (uint32_t)"0"),
93+
"ConnectorPhaseRotation", .str = "0"),
9494
FILL_KEY_TABLE(KEY_TYPE_INT, 0, CFG_CONN_PHASE_ROT_MAXLEN,
9595
"ConnectorPhaseRotationMaxLength", 1),
9696
FILL_KEY_TABLE(KEY_TYPE_BOOL, 1, CFG_STOP_TXN_ON_EVSIDE_DISCON,
9797
"StopTransactionOnEVSideDisconnect", 0),
9898
FILL_KEY_TABLE(KEY_TYPE_BOOL, 1, CFG_STOP_TXN_ON_INVL_ID,
9999
"StopTransactionOnInvalidId", 0),
100100
FILL_KEY_TABLE(KEY_TYPE_CSL, 1, CFG_STOP_TXN_ALIGNED_DATA,
101-
"StopTxnAlignedData", (uint32_t)"0"),
101+
"StopTxnAlignedData", .str = "0"),
102102
FILL_KEY_TABLE(KEY_TYPE_INT, 0, CFG_STOP_TXN_ALIGNED_DATA_MAXLEN,
103103
"StopTxnAlignedDataMaxLength", 1),
104104
FILL_KEY_TABLE(KEY_TYPE_CSL, 0, CFG_SUPPORTED_FEATURE_PROFILE,
105105
"SupportedFeatureProfiles",
106-
(uint32_t) CP_CORE CP_SC CP_RT CP_RE CP_LAL CP_FM),
106+
.str = CP_CORE CP_SC CP_RT CP_RE CP_LAL CP_FM),
107107
FILL_KEY_TABLE(KEY_TYPE_INT, 0, CFG_SUPPORTED_FEATURE_PROFILE_MAXLEN,
108108
"SupportedFeatureProfilesMaxLength", 6),
109109
FILL_KEY_TABLE(KEY_TYPE_INT, 1, CFG_TXN_MSG_ATTEMPTS,

subsys/net/lib/ocpp/ocpp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ static int ocpp_process_server_msg(struct ocpp_info *ctx)
326326

327327
if (is_rsp) {
328328
buf = strtok_r(uid, "-", &tmp);
329-
sh = (struct ocpp_session *) atoi(buf);
329+
sh = (struct ocpp_session *)(uintptr_t)atoi(buf);
330330

331331
buf = strtok_r(NULL, "-", &tmp);
332332
pdu = atoi(buf);

subsys/net/lib/ocpp/ocpp_j.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static int frame_authorize_msg(char *buf, int len,
114114
}
115115

116116
ret = frame_rpc_call_req(buf, len, PDU_AUTHORIZE,
117-
(uint32_t)ses, auth_obj);
117+
(uintptr_t)ses, auth_obj);
118118
if (ret < 0) {
119119
return ret;
120120
}
@@ -128,7 +128,7 @@ static int frame_heartbeat_msg(char *buf, int len, struct ocpp_session *ses)
128128
char tmp_buf[8] = "{}";
129129

130130
ret = frame_rpc_call_req(buf, len, PDU_HEARTBEAT,
131-
(uint32_t)ses, tmp_buf);
131+
(uintptr_t)ses, tmp_buf);
132132
if (ret < 0) {
133133
return ret;
134134
}
@@ -212,7 +212,7 @@ static int frame_bootnotif_msg(char *buf, int len,
212212
}
213213

214214
ret = frame_rpc_call_req(buf, len, PDU_BOOTNOTIFICATION,
215-
(uint32_t)ses, tmp_buf);
215+
(uintptr_t)ses, tmp_buf);
216216
if (ret < 0) {
217217
return ret;
218218
}
@@ -283,7 +283,7 @@ static int frame_meter_val_msg(char *buf, int len, struct ocpp_session *ses, cha
283283
}
284284

285285
ret = frame_rpc_call_req(buf, len, PDU_METER_VALUES,
286-
(uint32_t)ses, tmp_buf);
286+
(uintptr_t)ses, tmp_buf);
287287
if (ret < 0) {
288288
return ret;
289289
}
@@ -334,7 +334,7 @@ static int frame_stop_txn_msg(char *buf, int len, struct ocpp_session *ses,
334334
}
335335

336336
ret = frame_rpc_call_req(buf, len, PDU_STOP_TRANSACTION,
337-
(uint32_t)ses, tmp_buf);
337+
(uintptr_t)ses, tmp_buf);
338338
if (ret < 0) {
339339
return ret;
340340
}
@@ -381,7 +381,7 @@ static int frame_start_txn_msg(char *buf, int len, struct ocpp_session *ses,
381381
}
382382

383383
ret = frame_rpc_call_req(buf, len, PDU_START_TRANSACTION,
384-
(uint32_t)ses, tmp_buf);
384+
(uintptr_t)ses, tmp_buf);
385385
if (ret < 0) {
386386
return ret;
387387
}

0 commit comments

Comments
 (0)