Message ID | 20190110053407.9154-2-alex.hung@canonical.com |
---|---|
State | Superseded |
Headers | show |
Series | [1/2] lib: fwts_ac_adapter: fix readdir(ac_power_dir) failing | expand |
On 10/01/2019 05:34, Alex Hung wrote: > Some BIOS names adapter device "AC" which has length of 2. As a result, > it always fails to get AC directory. This removes the condition to have > directory name greater than 2. > > Signed-off-by: Alex Hung <alex.hung@canonical.com> > --- > src/lib/src/fwts_ac_adapter.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/lib/src/fwts_ac_adapter.c b/src/lib/src/fwts_ac_adapter.c > index de2242a2..fbf75b24 100644 > --- a/src/lib/src/fwts_ac_adapter.c > +++ b/src/lib/src/fwts_ac_adapter.c > @@ -103,7 +103,7 @@ int fwts_ac_adapter_get_state(const int state, int *matching, int *not_matching) > return FWTS_ERROR; > do { > entry = readdir(ac_power_dir); > - if (entry && strlen(entry->d_name) > 2) { I believe that code was to skip the "." and ".." links. I think the code should have been: if (entry && entry->d_name[0] != '.') { > + if (entry) { > char path[PATH_MAX]; > char *data; > >
On 1/10/19 1:34 PM, Alex Hung wrote: > Some BIOS names adapter device "AC" which has length of 2. As a result, > it always fails to get AC directory. This removes the condition to have > directory name greater than 2. > > Signed-off-by: Alex Hung <alex.hung@canonical.com> > --- > src/lib/src/fwts_ac_adapter.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/lib/src/fwts_ac_adapter.c b/src/lib/src/fwts_ac_adapter.c > index de2242a2..fbf75b24 100644 > --- a/src/lib/src/fwts_ac_adapter.c > +++ b/src/lib/src/fwts_ac_adapter.c > @@ -103,7 +103,7 @@ int fwts_ac_adapter_get_state(const int state, int *matching, int *not_matching) > return FWTS_ERROR; > do { > entry = readdir(ac_power_dir); > - if (entry && strlen(entry->d_name) > 2) { > + if (entry) { > char path[PATH_MAX]; > char *data; > Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/src/lib/src/fwts_ac_adapter.c b/src/lib/src/fwts_ac_adapter.c index de2242a2..fbf75b24 100644 --- a/src/lib/src/fwts_ac_adapter.c +++ b/src/lib/src/fwts_ac_adapter.c @@ -103,7 +103,7 @@ int fwts_ac_adapter_get_state(const int state, int *matching, int *not_matching) return FWTS_ERROR; do { entry = readdir(ac_power_dir); - if (entry && strlen(entry->d_name) > 2) { + if (entry) { char path[PATH_MAX]; char *data;
Some BIOS names adapter device "AC" which has length of 2. As a result, it always fails to get AC directory. This removes the condition to have directory name greater than 2. Signed-off-by: Alex Hung <alex.hung@canonical.com> --- src/lib/src/fwts_ac_adapter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)