Message ID | 20200505194749.36575-1-alex.hung@canonical.com |
---|---|
State | Superseded |
Headers | show |
Series | acpi/method: replace hardcoded array length | expand |
On 05/05/2020 20:47, Alex Hung wrote: > There are no functional changes > > Signed-off-by: Alex Hung <alex.hung@canonical.com> > --- > src/acpi/method/method.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c > index cd4d15c7..f6eb94ff 100644 > --- a/src/acpi/method/method.c > +++ b/src/acpi/method/method.c > @@ -4354,7 +4354,7 @@ static int method_test_BTP(fwts_framework *fw) > static const int values[] = { 0, 1, 100, 200, 0x7fffffff }; > int i; > > - for (i = 0; i < 5; i++) { > + for (i = 0; i < sizeof(values) / sizeof(int); i++) { It maybe better to use FWTS_ARRAY_SIZE(values) instead of size(values) / sizeof(int) since it can handle the change of the type of values too. > ACPI_OBJECT arg[1]; > arg[0].Type = ACPI_TYPE_INTEGER; > arg[0].Integer.Value = values[i]; > @@ -4394,7 +4394,7 @@ static int method_test_BTM(fwts_framework *fw) > static const int values[] = { 0, 1, 100, 200, 0x7fffffff }; > int i; > > - for (i = 0 ; i < 5; i++) { > + for (i = 0; i < sizeof(values) / sizeof(int); i++) { > ACPI_OBJECT arg[1]; > arg[0].Type = ACPI_TYPE_INTEGER; > arg[0].Integer.Value = values[i]; > @@ -4440,7 +4440,7 @@ static int method_test_BMC(fwts_framework *fw) > static const int values[] = { 0, 1, 2, 4 }; > int i; > > - for (i = 0; i < 4; i++) { > + for (i = 0; i < sizeof(values) / sizeof(int); i++) { > ACPI_OBJECT arg[1]; > arg[0].Type = ACPI_TYPE_INTEGER; > arg[0].Integer.Value = values[i]; >
On Tue, May 5, 2020 at 1:57 PM Colin Ian King <colin.king@canonical.com> wrote: > On 05/05/2020 20:47, Alex Hung wrote: > > There are no functional changes > > > > Signed-off-by: Alex Hung <alex.hung@canonical.com> > > --- > > src/acpi/method/method.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c > > index cd4d15c7..f6eb94ff 100644 > > --- a/src/acpi/method/method.c > > +++ b/src/acpi/method/method.c > > @@ -4354,7 +4354,7 @@ static int method_test_BTP(fwts_framework *fw) > > static const int values[] = { 0, 1, 100, 200, 0x7fffffff }; > > int i; > > > > - for (i = 0; i < 5; i++) { > > + for (i = 0; i < sizeof(values) / sizeof(int); i++) { > > It maybe better to use FWTS_ARRAY_SIZE(values) instead of size(values) / > sizeof(int) since it can handle the change of the type of values too. > Thanks. Will send v2. > > > > ACPI_OBJECT arg[1]; > > arg[0].Type = ACPI_TYPE_INTEGER; > > arg[0].Integer.Value = values[i]; > > @@ -4394,7 +4394,7 @@ static int method_test_BTM(fwts_framework *fw) > > static const int values[] = { 0, 1, 100, 200, 0x7fffffff }; > > int i; > > > > - for (i = 0 ; i < 5; i++) { > > + for (i = 0; i < sizeof(values) / sizeof(int); i++) { > > ACPI_OBJECT arg[1]; > > arg[0].Type = ACPI_TYPE_INTEGER; > > arg[0].Integer.Value = values[i]; > > @@ -4440,7 +4440,7 @@ static int method_test_BMC(fwts_framework *fw) > > static const int values[] = { 0, 1, 2, 4 }; > > int i; > > > > - for (i = 0; i < 4; i++) { > > + for (i = 0; i < sizeof(values) / sizeof(int); i++) { > > ACPI_OBJECT arg[1]; > > arg[0].Type = ACPI_TYPE_INTEGER; > > arg[0].Integer.Value = values[i]; > > > >
diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c index cd4d15c7..f6eb94ff 100644 --- a/src/acpi/method/method.c +++ b/src/acpi/method/method.c @@ -4354,7 +4354,7 @@ static int method_test_BTP(fwts_framework *fw) static const int values[] = { 0, 1, 100, 200, 0x7fffffff }; int i; - for (i = 0; i < 5; i++) { + for (i = 0; i < sizeof(values) / sizeof(int); i++) { ACPI_OBJECT arg[1]; arg[0].Type = ACPI_TYPE_INTEGER; arg[0].Integer.Value = values[i]; @@ -4394,7 +4394,7 @@ static int method_test_BTM(fwts_framework *fw) static const int values[] = { 0, 1, 100, 200, 0x7fffffff }; int i; - for (i = 0 ; i < 5; i++) { + for (i = 0; i < sizeof(values) / sizeof(int); i++) { ACPI_OBJECT arg[1]; arg[0].Type = ACPI_TYPE_INTEGER; arg[0].Integer.Value = values[i]; @@ -4440,7 +4440,7 @@ static int method_test_BMC(fwts_framework *fw) static const int values[] = { 0, 1, 2, 4 }; int i; - for (i = 0; i < 4; i++) { + for (i = 0; i < sizeof(values) / sizeof(int); i++) { ACPI_OBJECT arg[1]; arg[0].Type = ACPI_TYPE_INTEGER; arg[0].Integer.Value = values[i];
There are no functional changes Signed-off-by: Alex Hung <alex.hung@canonical.com> --- src/acpi/method/method.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)