Skip to content

Commit b95bbf1

Browse files
romanmichalvasko
authored andcommitted
server config REFACTOR assign structs
1 parent b6c64d3 commit b95bbf1

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

src/server_config.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3859,27 +3859,25 @@ static int
38593859
nc_server_config_create_interval(const char *anchor, const char *period)
38603860
{
38613861
int ret = 0;
3862-
struct nc_cert_exp_time cert_exp_time = {0};
3862+
struct nc_cert_exp_time anchor_time = {0}, period_time = {0};
38633863

38643864
server_opts.cert_exp_notif.intervals = nc_realloc(server_opts.cert_exp_notif.intervals,
38653865
(server_opts.cert_exp_notif.interval_count + 1) * sizeof *server_opts.cert_exp_notif.intervals);
38663866
NC_CHECK_ERRMEM_RET(!server_opts.cert_exp_notif.intervals, 1);
38673867

38683868
/* convert and set the anchor */
3869-
ret = nc_server_config_yang_value2cert_exp_time(anchor, &cert_exp_time);
3869+
ret = nc_server_config_yang_value2cert_exp_time(anchor, &anchor_time);
38703870
if (ret) {
38713871
goto cleanup;
38723872
}
3873-
memcpy(&server_opts.cert_exp_notif.intervals[server_opts.cert_exp_notif.interval_count].anchor,
3874-
&cert_exp_time, sizeof cert_exp_time);
3873+
server_opts.cert_exp_notif.intervals[server_opts.cert_exp_notif.interval_count].anchor = anchor_time;
38753874

38763875
/* convert and set the period */
3877-
ret = nc_server_config_yang_value2cert_exp_time(period, &cert_exp_time);
3876+
ret = nc_server_config_yang_value2cert_exp_time(period, &period_time);
38783877
if (ret) {
38793878
goto cleanup;
38803879
}
3881-
memcpy(&server_opts.cert_exp_notif.intervals[server_opts.cert_exp_notif.interval_count].period,
3882-
&cert_exp_time, sizeof cert_exp_time);
3880+
server_opts.cert_exp_notif.intervals[server_opts.cert_exp_notif.interval_count].period = period_time;
38833881

38843882
++server_opts.cert_exp_notif.interval_count;
38853883

@@ -3916,9 +3914,8 @@ nc_server_config_del_interval(const char *anchor, const char *period)
39163914
free(server_opts.cert_exp_notif.intervals);
39173915
server_opts.cert_exp_notif.intervals = NULL;
39183916
} else if (i != server_opts.cert_exp_notif.interval_count) {
3919-
memcpy(&server_opts.cert_exp_notif.intervals[i],
3920-
&server_opts.cert_exp_notif.intervals[server_opts.cert_exp_notif.interval_count],
3921-
sizeof *server_opts.cert_exp_notif.intervals);
3917+
server_opts.cert_exp_notif.intervals[i] =
3918+
server_opts.cert_exp_notif.intervals[server_opts.cert_exp_notif.interval_count];
39223919
}
39233920
}
39243921

0 commit comments

Comments
 (0)