MT#55283 include explicit cast in STR_INIT

Some source strings are `const char *` and we don't have an alternative
`str` type pointing to a const buffer. Strictly speaking some buffers
aren't even char buffers, yet we use the `str` type to manage them. This
eliminates the need to explicitly cast every usage.

Change-Id: Ifd3cdd3d400fc483e6c488a95e9381938e63cc7f
pull/1786/head
Richard Fuchs 1 year ago
parent 42d3ae33bb
commit 9bac9bc683

@ -1087,7 +1087,7 @@ static const char *janus_videoroom(struct websocket_message *wm, struct janus_se
const char *req = json_reader_get_string_value(reader);
if (!req)
goto err;
str req_str = STR_INIT((char*) req);
str req_str = STR_INIT(req);
json_reader_end_member(reader);
switch (__csh_lookup(&req_str)) {
@ -1789,7 +1789,7 @@ static const char *websocket_janus_process_json(struct websocket_message *wm,
ilog(LOG_DEBUG, "Processing '%s' type Janus message", janus_cmd);
str janus_cmd_str = STR_INIT((char*) janus_cmd);
str janus_cmd_str = STR_INIT(janus_cmd);
err = NULL;

@ -556,7 +556,7 @@ static int rtcp_rr(struct rtcp_chain_element *el, struct rtcp_process_ctx *log_c
static int rtcp_sdes(struct rtcp_chain_element *el, struct rtcp_process_ctx *log_ctx) {
CAH(sdes_list_start, el->sdes);
str comp_s = STR_INIT_LEN((void *) el->sdes->chunks, el->len - sizeof(el->sdes->header));
str comp_s = STR_INIT_LEN(el->sdes->chunks, el->len - sizeof(el->sdes->header));
int i = 0;
while (1) {
struct sdes_chunk *sdes_chunk = (struct sdes_chunk *) comp_s.s;

@ -104,7 +104,7 @@ static int t38_gateway_handler(t38_core_state_t *stat, void *user_data, const ui
g_string_append_len(s, (void *) &seq, 2);
// add primary IFP packet
str buf = STR_INIT_LEN((char *) b, len);
str buf = STR_INIT_LEN(b, len);
__add_udptl(s, &buf);
// add error correction packets

@ -37,8 +37,8 @@ TYPED_GQUEUE(str, str)
#define STR_NULL ((str) { NULL, 0 })
#define STR_EMPTY ((str) { "", 0 })
#define STR_CONST_INIT(s) ((str) { s, sizeof(s)-1 })
#define STR_INIT(s) ((str) { s, (s) ? strlen(s) : 0 })
#define STR_INIT_LEN(s, len) ((str) { s, len })
#define STR_INIT(s) ((str) { (char *) (s), (s) ? strlen(s) : 0 })
#define STR_INIT_LEN(s, len) ((str) { (char *) (s), len })
#define STR_INIT_DUP(s) ((str) { g_strdup(s), strlen(s) })
#define STR_CONST_INIT_BUF(buf) ((str) { (char *) &buf, sizeof(buf) })

@ -32,7 +32,7 @@ decode_t *decoder_new(const char *payload_str, const char *format, int ptime, ou
return NULL;
}
str name = STR_INIT_LEN((char *) payload_str, slash - payload_str);
str name = STR_INIT_LEN(payload_str, slash - payload_str);
int clockrate = atoi(slash + 1);
if (clockrate <= 0) {
ilog(LOG_ERR, "Invalid clock rate %i (parsed from '%.20s'/'%.20s')",
@ -82,7 +82,7 @@ decode_t *decoder_new(const char *payload_str, const char *format, int ptime, ou
else
out_format.format = AV_SAMPLE_FMT_S16; // needed for TLS-only scenarios
str fmtp = STR_INIT((char*) format);
str fmtp = STR_INIT(format);
decoder_t *dec = decoder_new_fmtp(def, rtp_clockrate, channels, ptime, &out_format, NULL, &fmtp, NULL);
if (!dec)

Loading…
Cancel
Save