Message ID | 20200729040350.13664-2-ivan.hu@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/2] lib: fwts_battery: fix build error on armhf | expand |
On 2020-07-28 10:03 p.m., Ivan Hu wrote: > For fixing gcc-10 generates build errors on armhf. > > Signed-off-by: Ivan Hu <ivan.hu@canonical.com> > --- > src/lib/src/fwts_button.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/src/lib/src/fwts_button.c b/src/lib/src/fwts_button.c > index b2be77f7..591085ca 100644 > --- a/src/lib/src/fwts_button.c > +++ b/src/lib/src/fwts_button.c > @@ -26,9 +26,24 @@ > #include <string.h> > #include <limits.h> > #include <dirent.h> > +#include <bsd/string.h> > > #define FWTS_PROC_ACPI_BUTTON "/proc/acpi/button" > > +static inline void fwts_button_path( > + char *path, > + const size_t path_len, > + const char *button_dir, > + const char *name, > + const char *str) > +{ > + (void)strlcpy(path, button_dir, path_len); > + (void)strlcat(path, "/", path_len); > + (void)strlcat(path, name, path_len); > + (void)strlcat(path, "/", path_len); > + (void)strlcat(path, str, path_len); > +} > + > /* > * fwts_button_match_state_proc() > * find matching button state and keep count of matching > @@ -80,7 +95,8 @@ static int fwts_button_match_state_proc( > char path[PATH_MAX]; > char *data; > > - snprintf(path, sizeof(path), "%s/%s/%s", button_dir, entry->d_name, field); > + fwts_button_path(path, sizeof(path), button_dir, entry->d_name, field); > + > if ((data = fwts_get(path)) != NULL) { > if (strstr(data, match)) > (*matched)++; > Acked-by: Alex Hung <alex.hung@canonical.com>
On 29/07/2020 05:03, Ivan Hu wrote: > For fixing gcc-10 generates build errors on armhf. > > Signed-off-by: Ivan Hu <ivan.hu@canonical.com> > --- > src/lib/src/fwts_button.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/src/lib/src/fwts_button.c b/src/lib/src/fwts_button.c > index b2be77f7..591085ca 100644 > --- a/src/lib/src/fwts_button.c > +++ b/src/lib/src/fwts_button.c > @@ -26,9 +26,24 @@ > #include <string.h> > #include <limits.h> > #include <dirent.h> > +#include <bsd/string.h> > > #define FWTS_PROC_ACPI_BUTTON "/proc/acpi/button" > > +static inline void fwts_button_path( > + char *path, > + const size_t path_len, > + const char *button_dir, > + const char *name, > + const char *str) > +{ > + (void)strlcpy(path, button_dir, path_len); > + (void)strlcat(path, "/", path_len); > + (void)strlcat(path, name, path_len); > + (void)strlcat(path, "/", path_len); > + (void)strlcat(path, str, path_len); > +} > + > /* > * fwts_button_match_state_proc() > * find matching button state and keep count of matching > @@ -80,7 +95,8 @@ static int fwts_button_match_state_proc( > char path[PATH_MAX]; > char *data; > > - snprintf(path, sizeof(path), "%s/%s/%s", button_dir, entry->d_name, field); > + fwts_button_path(path, sizeof(path), button_dir, entry->d_name, field); > + > if ((data = fwts_get(path)) != NULL) { > if (strstr(data, match)) > (*matched)++; > Acked-by: Colin Ian King <colin.king@canonical.com>
diff --git a/src/lib/src/fwts_button.c b/src/lib/src/fwts_button.c index b2be77f7..591085ca 100644 --- a/src/lib/src/fwts_button.c +++ b/src/lib/src/fwts_button.c @@ -26,9 +26,24 @@ #include <string.h> #include <limits.h> #include <dirent.h> +#include <bsd/string.h> #define FWTS_PROC_ACPI_BUTTON "/proc/acpi/button" +static inline void fwts_button_path( + char *path, + const size_t path_len, + const char *button_dir, + const char *name, + const char *str) +{ + (void)strlcpy(path, button_dir, path_len); + (void)strlcat(path, "/", path_len); + (void)strlcat(path, name, path_len); + (void)strlcat(path, "/", path_len); + (void)strlcat(path, str, path_len); +} + /* * fwts_button_match_state_proc() * find matching button state and keep count of matching @@ -80,7 +95,8 @@ static int fwts_button_match_state_proc( char path[PATH_MAX]; char *data; - snprintf(path, sizeof(path), "%s/%s/%s", button_dir, entry->d_name, field); + fwts_button_path(path, sizeof(path), button_dir, entry->d_name, field); + if ((data = fwts_get(path)) != NULL) { if (strstr(data, match)) (*matched)++;
For fixing gcc-10 generates build errors on armhf. Signed-off-by: Ivan Hu <ivan.hu@canonical.com> --- src/lib/src/fwts_button.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)