Message ID | 1463161029-7490-1-git-send-email-falakreyaz@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Am 13.05.2016 um 19:36 schrieb Muhammad Falak R Wani: > It is preferred to use ARRAY_SIZE() for size calculation, instead > using sizeof(array)/sizeof(*array). It makes the code more readable. > > Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com> Reviewed-by: Christian König <christian.koenig@amd.com> Thanks for the cleanup, Christian. > --- > drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c > index da18f44..87c023e 100644 > --- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c > +++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c > @@ -639,7 +639,7 @@ static int cz_smu_populate_firmware_entries(struct pp_smumgr *smumgr) > > cz_smu->driver_buffer_length = 0; > > - for (i = 0; i < sizeof(firmware_list)/sizeof(*firmware_list); i++) { > + for (i = 0; i < ARRAY_SIZE(firmware_list); i++) { > > firmware_type = cz_translate_firmware_enum_to_arg(smumgr, > firmware_list[i]);
On Fri, May 13, 2016 at 11:06:40PM +0530, Muhammad Falak R Wani wrote: > It is preferred to use ARRAY_SIZE() for size calculation, instead > using sizeof(array)/sizeof(*array). It makes the code more readable. > > Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Thanks, and sorry about before, if I made you feel like you made a "childish mistake". As Dan said, this is mostly a question of style: your code was right, it just had an unnecessary bit. I hope I didn't give you a bad impression of the community, most people around here have better manners than I :P Cheers
On Fri, May 13, 2016 at 1:36 PM, Muhammad Falak R Wani <falakreyaz@gmail.com> wrote: > It is preferred to use ARRAY_SIZE() for size calculation, instead > using sizeof(array)/sizeof(*array). It makes the code more readable. > > Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com> Applied. thanks! Alex > --- > drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c > index da18f44..87c023e 100644 > --- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c > +++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c > @@ -639,7 +639,7 @@ static int cz_smu_populate_firmware_entries(struct pp_smumgr *smumgr) > > cz_smu->driver_buffer_length = 0; > > - for (i = 0; i < sizeof(firmware_list)/sizeof(*firmware_list); i++) { > + for (i = 0; i < ARRAY_SIZE(firmware_list); i++) { > > firmware_type = cz_translate_firmware_enum_to_arg(smumgr, > firmware_list[i]); > -- > 1.9.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel
On Mon, May 16, 2016 at 04:53:50PM +0100, Eric Engestrom wrote: > On Fri, May 13, 2016 at 11:06:40PM +0530, Muhammad Falak R Wani wrote: > > It is preferred to use ARRAY_SIZE() for size calculation, instead > > using sizeof(array)/sizeof(*array). It makes the code more readable. > > > > Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com> > > Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> > > Thanks, and sorry about before, if I made you feel like you made > a "childish mistake". As Dan said, this is mostly a question of > style: your code was right, it just had an unnecessary bit. > > I hope I didn't give you a bad impression of the community, most > people around here have better manners than I :P > > Cheers Thank you for such a nice gesture. No, I didn't get any bad impression. Infact people learn like this. Thank you guys :)
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c index da18f44..87c023e 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c @@ -639,7 +639,7 @@ static int cz_smu_populate_firmware_entries(struct pp_smumgr *smumgr) cz_smu->driver_buffer_length = 0; - for (i = 0; i < sizeof(firmware_list)/sizeof(*firmware_list); i++) { + for (i = 0; i < ARRAY_SIZE(firmware_list); i++) { firmware_type = cz_translate_firmware_enum_to_arg(smumgr, firmware_list[i]);
It is preferred to use ARRAY_SIZE() for size calculation, instead using sizeof(array)/sizeof(*array). It makes the code more readable. Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com> --- drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)