Skip to content

Commit

Permalink
Update liblcb: Remove syntax shugar.
Browse files Browse the repository at this point in the history
  • Loading branch information
rozhuk-im committed Apr 28, 2024
1 parent 0de5f79 commit 1a8b8d1
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 33 deletions.
2 changes: 1 addition & 1 deletion msd.project
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
</VirtualDirectory>
<Settings Type="Executable">
<GlobalSettings>
<Compiler Options="" C_Options="-fsanitize=safe-stack;-fPIE;-D_FORTIFY_SOURCE=2;-fstack-protector;-fomit-frame-pointer;-DTHREAD_POOL_SETTINGS_XML;-DHTTP_SRV_XML_CONFIG;-DSOCKET_XML_CONFIG;-DMPEG2TS_XML_CONFIG;-DHAVE_PIPE2;-DHAVE_ACCEPT4;-DHAVE_MEMRCHR;-DHAVE_MEMMEM;-DHAVE_REALLOCARRAY;-DHAVE_MEMSET_S;-DHAVE_EXPLICIT_BZERO;-DHAVE_STRLCPY;-DHAVE_KQUEUEX" Assembler="">
<Compiler Options="" C_Options="-fsanitize=safe-stack;-fPIE;-D_FORTIFY_SOURCE=2;-fstack-protector;-fomit-frame-pointer;-DTHREAD_POOL_SETTINGS_XML;-DHTTP_SRV_XML_CONFIG;-DSOCKET_XML_CONFIG;-DMPEG2TS_XML_CONFIG;-DHAVE_PIPE2;-DHAVE_ACCEPT4;-DHAVE_MEMRCHR;-DHAVE_MEMMEM;-DHAVE_REALLOCARRAY;-DHAVE_MEMSET_S;-DHAVE_EXPLICIT_BZERO;-DHAVE_STRLCPY;-DHAVE_KQUEUEX;-DHAVE_TIMINGSAFE_BCMP" Assembler="">
<IncludePath Value="$(IntermediateDirectory)"/>
<IncludePath Value="../"/>
<IncludePath Value="../src"/>
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(MSD_BIN msd.c
liblcb/src/utils/info.c
liblcb/src/utils/ring_buffer.c
liblcb/src/utils/xml.c)

add_executable(msd ${MSD_BIN})
target_compile_definitions(msd PRIVATE -DMPEG2TS_XML_CONFIG)
target_compile_definitions(msd PRIVATE -DHTTP_SRV_XML_CONFIG)
Expand Down
8 changes: 4 additions & 4 deletions src/dvb_fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ dvb_fe_props_clr(struct dtv_properties *cmdseq) {
if (NULL == cmdseq)
return;
cmdseq->num = 0;
mem_bzero(cmdseq->props, (sizeof(struct dtv_property) * DTV_IOCTL_MAX_MSGS));
memset(cmdseq->props, 0x00, (sizeof(struct dtv_property) * DTV_IOCTL_MAX_MSGS));
}

static inline void
Expand Down Expand Up @@ -293,7 +293,7 @@ dvb_fe_create(uint32_t adapter_idx, uint32_t fe_idx, tpt_p tpt,

if (NULL == tpt || NULL == dvb_fe_ret)
return (EINVAL);
dvb_fe = zalloc(sizeof(dvb_fe_t));
dvb_fe = calloc(1, sizeof(dvb_fe_t));
if (NULL == dvb_fe)
return (ENOMEM);
dvb_fe->adapter_idx = adapter_idx;
Expand Down Expand Up @@ -321,7 +321,7 @@ dvb_fe_settings_def(dvb_fe_settings_p s_ret) {

if (NULL == s_ret)
return;
mem_bzero(s_ret, sizeof(dvb_fe_settings_t));
memset(s_ret, 0x00, sizeof(dvb_fe_settings_t));
s_ret->delivery_sys = SYS_UNDEFINED;
//s_ret->frequency;
s_ret->modulation = QAM_AUTO;
Expand Down Expand Up @@ -631,7 +631,7 @@ dvb_fe_tune(dvb_fe_p dvb_fe) {
dvb_fe->adapter_idx, dvb_fe->fe_idx);
return (EINVAL);
}
mem_bzero(&feparams, sizeof(struct dvb_frontend_parameters));
memset(&feparams, 0x00, sizeof(struct dvb_frontend_parameters));
feparams.frequency = dvb_fe->frequency;
feparams.inversion = dvb_fe->s.spec_inv;

Expand Down
2 changes: 1 addition & 1 deletion src/liblcb
Submodule liblcb updated 47 files
+1 −0 CMakeLists.txt
+1 −1 include/al/hw.h
+29 −15 include/al/os.h
+1 −1 include/crypto/hash/gost3411-2012.h
+1 −1 include/crypto/hash/md5.h
+1 −1 include/crypto/hash/sha1.h
+1 −1 include/crypto/hash/sha2.h
+1 −1 include/math/big_num.h
+5 −5 include/net/host_address.h
+5 −3 include/net/hostname_list.h
+1 −1 include/proto/dns.h
+5 −19 include/proto/radius.h
+12 −4 include/threadpool/threadpool.h
+1 −1 include/utils/hash_bucket.h
+4 −46 include/utils/mem_utils.h
+1 −3 lib.project
+8 −0 liblcb.workspace
+8 −9 src/net/socket.c
+4 −4 src/net/socket_address.c
+4 −6 src/net/socket_options.c
+1 −1 src/net/utils.c
+4 −4 src/proto/bt_tracker.c
+8 −7 src/proto/dns_resolv.c
+2 −2 src/proto/http.c
+7 −7 src/proto/http_client.c
+10 −9 src/proto/http_server.c
+2 −2 src/proto/http_server_auth.c
+13 −14 src/proto/radius_client.c
+3 −3 src/proto/sap_rcvr.c
+8 −8 src/proto/upnp_ssdp.c
+123 −67 src/threadpool/threadpool.c
+4 −4 src/threadpool/threadpool_msg_sys.c
+4 −4 src/threadpool/threadpool_task.c
+2 −2 src/utils/bt_encode.c
+4 −4 src/utils/buf_str.c
+1 −1 src/utils/cmd_line_daemon.c
+4 −5 src/utils/data_cache.c
+2 −1 src/utils/info.c
+3 −3 src/utils/ini.c
+2 −2 src/utils/ring_buffer.c
+3 −3 src/utils/sys.c
+1 −1 src/utils/sys_res_limits_xml.c
+2 −2 src/utils/xml.c
+1 −1 tests/base64/main.c
+1 −1 tests/ecdsa/main.c
+17 −5 tests/threadpool/main.c
+38 −1 tests/threadpool/test-threadpool.project
6 changes: 3 additions & 3 deletions src/msd.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ msd_prog_service_load(const uint8_t *buf, size_t buf_size, const char *name,

if (NULL == buf || 0 == buf_size || NULL == srv)
return (EINVAL);
mem_bzero(srv, sizeof(prog_service_t));
memset(srv, 0x00, sizeof(prog_service_t));

/* Read from config. */
if (0 == xml_get_val_args(buf, buf_size, NULL, NULL, NULL, &ptm, &tm,
Expand Down Expand Up @@ -336,7 +336,7 @@ msd_channel_load(prog_settings_p ps, const uint8_t *cfg_file_buf, size_t cfg_fil
if (NULL == ps || NULL == cfg_file_buf || 0 == cfg_file_buf_size ||
NULL == data || 0 == data_size)
return (EINVAL);
hub_params = zalloc(sizeof(str_hub_settings_t));
hub_params = calloc(1, sizeof(str_hub_settings_t));
if (NULL == hub_params) {
error = ENOMEM;
goto err_out;
Expand Down Expand Up @@ -504,7 +504,7 @@ main(int argc, char *argv[]) {
str_hubs_bckt_p shbskt;
cmd_line_data_t cmd_line_data;

mem_bzero(&g_data, sizeof(g_data));
memset(&g_data, 0x00, sizeof(g_data));
if (0 != cmd_line_parse(argc, argv, &cmd_line_data)) {
cmd_line_usage(PACKAGE_DESCRIPTION, PACKAGE_VERSION,
"Rozhuk Ivan <[email protected]>",
Expand Down
4 changes: 2 additions & 2 deletions src/src_dvb.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ src_dvb_settings_def(src_dvb_settings_p s_ret) {

if (NULL == s_ret)
return;
mem_bzero(s_ret, sizeof(dvb_fe_settings_t));
memset(s_ret, 0x00, sizeof(dvb_fe_settings_t));
dvb_fe_settings_def(&s_ret->fe_s);
}

Expand Down Expand Up @@ -97,7 +97,7 @@ src_dvb_create(src_dvb_settings_p s, tpt_p tpt, src_dvb_p *src_dvb_ret) {

if (NULL == s || NULL == tpt || NULL == src_dvb_ret)
return (EINVAL);
src_dvb = zalloc(sizeof(src_dvb_t));
src_dvb = calloc(1, sizeof(src_dvb_t));
if (NULL == src_dvb)
return (ENOMEM);
/* Settings. */
Expand Down
24 changes: 12 additions & 12 deletions src/stream_hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ str_hub_settings_def(str_hub_settings_p s_ret) {

if (NULL == s_ret)
return;
mem_bzero(s_ret, sizeof(str_hub_settings_t));
memset(s_ret, 0x00, sizeof(str_hub_settings_t));
skt_opts_init(STR_HUB_S_SKT_OPTS_INT_MASK,
STR_HUB_S_SKT_OPTS_INT_VALS, &s_ret->skt_opts);
s_ret->skt_opts.mask |= SO_F_NONBLOCK;
Expand Down Expand Up @@ -315,11 +315,11 @@ str_hubs_bckt_create(tp_p tp, const char *app_ver,

if (NULL == shbskt_ret)
return (EINVAL);
shbskt = zalloc(sizeof(str_hubs_bckt_t));
shbskt = calloc(1, sizeof(str_hubs_bckt_t));
if (NULL == shbskt)
return (ENOMEM);
thread_count_max = tp_thread_count_max_get(tp);
shbskt->thr_data = zalloc((sizeof(str_hub_thrd_t) * thread_count_max));
shbskt->thr_data = calloc(1, (sizeof(str_hub_thrd_t) * thread_count_max));
if (NULL == shbskt->thr_data) {
error = ENOMEM;
goto err_out;
Expand Down Expand Up @@ -457,7 +457,7 @@ str_hubs_bckt_stat_summary(str_hubs_bckt_p shbskt, str_hubs_stat_p stat) {
if (NULL == shbskt || NULL == stat)
return (EINVAL);
thread_cnt = tp_thread_count_max_get(shbskt->tp);
mem_bzero(stat, sizeof(str_hubs_stat_t));
memset(stat, 0x00, sizeof(str_hubs_stat_t));
for (i = 0; i < thread_cnt; i ++) {
stat->str_hub_count += shbskt->thr_data[i].stat.str_hub_count;
stat->cli_count += shbskt->thr_data[i].stat.cli_count;
Expand Down Expand Up @@ -555,7 +555,7 @@ str_hubs_bckt_timer_msg_cb(tpt_p tpt, void *udata) {
//SYSLOGD_EX(LOG_DEBUG, "...");

thread_num = tp_thread_get_num(tpt);
mem_bzero(&stat, sizeof(str_hubs_stat_t));
memset(&stat, 0x00, sizeof(str_hubs_stat_t));

/* Enum all Stream Hubs associated with this thread. */
TAILQ_FOREACH_SAFE(str_hub, &shbskt->thr_data[thread_num].hub_head,
Expand Down Expand Up @@ -636,7 +636,7 @@ str_hub_create(str_hubs_bckt_p shbskt, tpt_p tpt,
return (EEXIST);
}
/* Create new. */
str_hub = zalloc((sizeof(str_hub_t) + name_size + sizeof(void*)));
str_hub = calloc(1, (sizeof(str_hub_t) + name_size + sizeof(void*)));
if (NULL == str_hub)
return (ENOMEM);
str_hub->shbskt = shbskt;
Expand All @@ -650,7 +650,7 @@ str_hub_create(str_hubs_bckt_p shbskt, tpt_p tpt,
str_hub->tpt = tpt;
//str_hub->src = NULL;
//str_hub->src_cnt = 0;
//mem_bzero(&str_hub->s, sizeof(str_hub_settings_t));
//memset(&str_hub->s, 0x00, sizeof(str_hub_settings_t));

TAILQ_INSERT_HEAD(&shbskt->thr_data[tp_thread_get_num(tpt)].hub_head,
str_hub, next);
Expand Down Expand Up @@ -748,7 +748,7 @@ str_hub_cli_alloc(uint32_t cli_type, uint32_t cli_sub_type) {

SYSLOGD_EX(LOG_DEBUG, "...");

strh_cli = zalloc(sizeof(str_hub_cli_t));
strh_cli = calloc(1, sizeof(str_hub_cli_t));
if (NULL == strh_cli)
return (NULL);
/* Set. */
Expand Down Expand Up @@ -926,7 +926,7 @@ str_hub_cli_send_http_hdr(str_hubs_bckt_p shbskt, str_hub_cli_p strh_cli,
if (NULL == strh_cli || NULL == shbskt)
return (EINVAL);
str_hub = strh_cli->str_hub;
mem_bzero(&mhdr, sizeof(mhdr));
memset(&mhdr, 0x00, sizeof(mhdr));
/* Gen HTTP resp line + headers. */
mhdr.msg_iov = (struct iovec*)iov;
mhdr.msg_iovlen = 3;
Expand Down Expand Up @@ -984,7 +984,7 @@ str_hub_send_msg(str_hubs_bckt_p shbskt, const uint8_t *name, size_t name_size,
if (NULL == shbskt || NULL == name ||
0 == name_size || STR_HUB_NAME_MAX_SIZE <= name_size)
return (EINVAL);
msg_data = zalloc(sizeof(str_hub_msg_data_t) + name_size + sizeof(void*));
msg_data = calloc(1, sizeof(str_hub_msg_data_t) + name_size + sizeof(void*));
if (NULL == msg_data)
return (ENOMEM);
msg_data->shbskt = shbskt;
Expand Down Expand Up @@ -1191,7 +1191,7 @@ str_hub_send_to_client(str_hub_cli_p strh_cli, struct timespec *ts,
0 != (STR_SRC_S_F_M2TS_ANALYZING & str_hub->src[str_hub->src_current]->s.flags) &&
NULL != str_hub->src[str_hub->src_current]->m2ts) {
m2ts = str_hub->src[str_hub->src_current]->m2ts;
mem_bzero(&mhdr, sizeof(mhdr));
memset(&mhdr, 0x00, sizeof(mhdr));
mhdr.msg_iov = (struct iovec*)thr_data->iov;
mhdr.msg_iovlen = (int)(2 + m2ts->prog_cnt);
thr_data->iov[0].iov_base = m2ts->pat.ts_psi_packets;
Expand Down Expand Up @@ -1324,7 +1324,7 @@ str_hub_send_to_client(str_hub_cli_p strh_cli, struct timespec *ts,
break;
}
} else { /* Old way. */
mem_bzero(&mhdr, sizeof(mhdr));
memset(&mhdr, 0x00, sizeof(mhdr));
mhdr.msg_iov = (struct iovec*)thr_data->iov;
mhdr.msg_iovlen = (int)iov_cnt;
ios = sendmsg((int)ident, &mhdr, (MSG_DONTWAIT | MSG_NOSIGNAL));
Expand Down
14 changes: 7 additions & 7 deletions src/stream_mpeg2ts.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ mpeg2_ts_def_settings(mpeg2_ts_settings_p s) {
if (NULL == s)
return;
/* Init. */
mem_bzero(s, sizeof(mpeg2_ts_settings_t));
memset(s, 0x00, sizeof(mpeg2_ts_settings_t));

/* Default settings. */
s->pids_flt.pids_count = 0;
Expand Down Expand Up @@ -232,7 +232,7 @@ mpeg2_ts_settings_copy(mpeg2_ts_settings_p dst, mpeg2_ts_settings_p src) {
} else {
SYSLOGD_EX(LOG_DEBUG, "mem=%zx, count=%zu",
(size_t)dst->pids_flt.pids, dst->pids_flt.pids_count);
dst->pids_flt.pids = mallocarray(dst->pids_flt.pids_count,
dst->pids_flt.pids = reallocarray(NULL, dst->pids_flt.pids_count,
sizeof(uint32_t));
if (NULL == dst->pids_flt.pids) {
dst->pids_flt.pids_count = 0;
Expand Down Expand Up @@ -267,7 +267,7 @@ mpeg2_ts_data_alloc(mpeg2_ts_data_p *m2ts_ret, mpeg2_ts_settings_p s) {

SYSLOGD_EX(LOG_DEBUG, "...");

m2ts = zalloc(sizeof(mpeg2_ts_data_t));
m2ts = calloc(1, sizeof(mpeg2_ts_data_t));
if (NULL == m2ts)
return (ENOMEM);
m2ts->mpeg2_ts_pkt_size = MPEG2_TS_PKT_SIZE_188;
Expand Down Expand Up @@ -349,7 +349,7 @@ mpeg2_ts_data_progs_realloc(mpeg2_ts_data_p m2ts, size_t count) {
if (NULL == progs) /* Realloc fail! */
return (ENOMEM);
if (count > m2ts->prog_allocated) { /* Init progs. */
mem_bzero(&progs[m2ts->prog_allocated],
memset(&progs[m2ts->prog_allocated], 0x00,
((count - m2ts->prog_allocated) * sizeof(mpeg2_ts_prog_t)));
}
m2ts->progs = progs;
Expand Down Expand Up @@ -389,7 +389,7 @@ mpeg2_ts_data_pids_realloc(mpeg2_ts_data_p m2ts, size_t count) {
if (NULL == pids) /* Realloc fail! */
return (ENOMEM);
if (count > m2ts->data_pids_allocated) { /* Init pids. */
mem_bzero(&pids[m2ts->data_pids_allocated],
memset(&pids[m2ts->data_pids_allocated], 0x00,
((count - m2ts->data_pids_allocated) * sizeof(mpeg2_ts_pid_t)));
}
m2ts->data_pids = pids;
Expand Down Expand Up @@ -435,7 +435,7 @@ mpeg2_ts_data_pids_cleanup(mpeg2_ts_data_p m2ts) {
memmove(&m2ts->data_pids[i], &m2ts->data_pids[(i + 1)],
((count - (i + 1)) * sizeof(mpeg2_ts_pid_t)));
count --;
mem_bzero(&m2ts->data_pids[count], sizeof(mpeg2_ts_pid_t));
memset(&m2ts->data_pids[count], 0x00, sizeof(mpeg2_ts_pid_t));
}
m2ts->data_pids_cnt = count;
return (mpeg2_ts_data_pids_realloc(m2ts, count));
Expand Down Expand Up @@ -645,7 +645,7 @@ mpeg2_ts_pid_psi_tbls_realloc(mpeg2_ts_pid_p ts_pid, size_t count) {
if (NULL == psi_tbls) /* Realloc fail! */
return (ENOMEM);
if (count > ts_pid->psi_tbls_allocated) { /* Init psi_tbls. */
mem_bzero(&psi_tbls[ts_pid->psi_tbls_allocated],
memset(&psi_tbls[ts_pid->psi_tbls_allocated], 0x00,
((count - ts_pid->psi_tbls_allocated) * sizeof(mpeg2_ts_psi_tbl_t)));
}
ts_pid->psi_tbls = psi_tbls;
Expand Down
6 changes: 3 additions & 3 deletions src/stream_src.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ str_src_settings_def(str_src_settings_p s_ret) {

if (NULL == s_ret)
return;
mem_bzero(s_ret, sizeof(str_src_settings_t));
memset(s_ret, 0x00, sizeof(str_src_settings_t));

skt_opts_init(STR_SRC_S_SKT_OPTS_INT_MASK,
STR_SRC_S_SKT_OPTS_INT_VALS, &s_ret->skt_opts);
Expand Down Expand Up @@ -360,7 +360,7 @@ str_src_conn_def(uint32_t type, str_src_conn_params_p src_conn_params) {

if (NULL == src_conn_params)
return;
mem_bzero(src_conn_params, sizeof(str_src_conn_params_t));
memset(src_conn_params, 0x00, sizeof(str_src_conn_params_t));

switch (type) {
case STR_SRC_TYPE_UDP:
Expand Down Expand Up @@ -583,7 +583,7 @@ str_src_create(uint32_t type, str_src_settings_p s, tpt_p tpt,
default:
return (EINVAL);
}
src = zalloc((sizeof(str_src_t) + sizeof(str_src_conn_params_t) + 64));
src = calloc(1, (sizeof(str_src_t) + sizeof(str_src_conn_params_t) + 64));
if (NULL == src)
return (ENOMEM);
/* Settings. */
Expand Down

0 comments on commit 1a8b8d1

Please sign in to comment.