From 1a8b8d17fab98d6566994422e225bc01b3765d2f Mon Sep 17 00:00:00 2001 From: Rozhuk Ivan Date: Sun, 28 Apr 2024 23:30:06 +0300 Subject: [PATCH] Update liblcb: Remove syntax shugar. --- msd.project | 2 +- src/CMakeLists.txt | 1 + src/dvb_fe.c | 8 ++++---- src/liblcb | 2 +- src/msd.c | 6 +++--- src/src_dvb.c | 4 ++-- src/stream_hub.c | 24 ++++++++++++------------ src/stream_mpeg2ts.c | 14 +++++++------- src/stream_src.c | 6 +++--- 9 files changed, 34 insertions(+), 33 deletions(-) diff --git a/msd.project b/msd.project index f830dd0..c762dab 100644 --- a/msd.project +++ b/msd.project @@ -143,7 +143,7 @@ - + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 24c4264..f7f08ab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/dvb_fe.c b/src/dvb_fe.c index e116825..c2f2ac8 100644 --- a/src/dvb_fe.c +++ b/src/dvb_fe.c @@ -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 @@ -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; @@ -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; @@ -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; diff --git a/src/liblcb b/src/liblcb index 4db42f6..dea7b69 160000 --- a/src/liblcb +++ b/src/liblcb @@ -1 +1 @@ -Subproject commit 4db42f6a957e9b96595268c381e8a3930aea2cff +Subproject commit dea7b6937d762459f6cce4650e1b4829872b355f diff --git a/src/msd.c b/src/msd.c index aa8ed8d..a537f59 100644 --- a/src/msd.c +++ b/src/msd.c @@ -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, @@ -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; @@ -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 ", diff --git a/src/src_dvb.c b/src/src_dvb.c index 39038cc..73b8078 100644 --- a/src/src_dvb.c +++ b/src/src_dvb.c @@ -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); } @@ -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. */ diff --git a/src/stream_hub.c b/src/stream_hub.c index f028b49..6db456e 100644 --- a/src/stream_hub.c +++ b/src/stream_hub.c @@ -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; @@ -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; @@ -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; @@ -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, @@ -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; @@ -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); @@ -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. */ @@ -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; @@ -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; @@ -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; @@ -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)); diff --git a/src/stream_mpeg2ts.c b/src/stream_mpeg2ts.c index 4652466..7aae3fd 100644 --- a/src/stream_mpeg2ts.c +++ b/src/stream_mpeg2ts.c @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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)); @@ -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; diff --git a/src/stream_src.c b/src/stream_src.c index 6832017..449433f 100644 --- a/src/stream_src.c +++ b/src/stream_src.c @@ -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); @@ -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: @@ -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. */