Skip to content

Commit

Permalink
fix(calendar): Remove not needed strncpy
Browse files Browse the repository at this point in the history
  • Loading branch information
C47D committed Jan 9, 2024
1 parent b8cf15d commit 33608a7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/widgets/calendar/lv_calendar_header_dropdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,9 @@ static void year_event_cb(lv_event_t * e)

/* Get the first year on the options list
* NOTE: Assumes the first 4 digits in the option list are numbers */
char year_buf[YEAR_STR_BUFFER_LEN] = {0};
const char * year_p = lv_dropdown_get_options(dropdown);
strncpy(year_buf, year_p, DIGITS_IN_YEAR);
const uint32_t year = (year_buf[0] - '0') * 1000 + (year_buf[1] - '0') * 100 + (year_buf[2] - '0') * 10 +
(year_buf[3] - '0');
const uint32_t year = (year_p[0] - '0') * 1000 + (year_p[1] - '0') * 100 + (year_p[2] - '0') * 10 +
(year_p[3] - '0');

lv_calendar_date_t newd = *d;
newd.year = year - sel;
Expand All @@ -160,11 +158,9 @@ static void value_changed_event_cb(lv_event_t * e)

/* Get the first year on the options list
* NOTE: Assumes the first 4 digits in the option list are numbers */
char year_buf[YEAR_STR_BUFFER_LEN] = {0};
const char * year_p = lv_dropdown_get_options(year_dd);
strncpy(year_buf, year_p, DIGITS_IN_YEAR);
const uint32_t year = (year_buf[0] - '0') * 1000 + (year_buf[1] - '0') * 100 + (year_buf[2] - '0') * 10 +
(year_buf[3] - '0');
const uint32_t year = (year_p[0] - '0') * 1000 + (year_p[1] - '0') * 100 + (year_p[2] - '0') * 10 +
(year_p[3] - '0');

lv_dropdown_set_selected(year_dd, year - cur_date->year);

Expand Down

0 comments on commit 33608a7

Please sign in to comment.