2018-10-23 01:21:37

by Leonardo Brás

[permalink] [raw]
Subject: [PATCH 1/1] Changes style to look more like list iteration.

Changes the code in order to make it looks more like its a list iteration.

Signed-off-by: Leonardo Brás <[email protected]>
---

It's a remainer from a patch from the -Wshadow patchset.
Since it doesn't really belongs to that patchset anymore,
I decided to release it just as a code refactor for
file2alias.c

I fixed it after Koike's suggestion (&&!dup added)

IMHO it reads better this way, and no drastic change has been made.

Thanks.

---
scripts/mod/file2alias.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 3015c0bdecb2..b957279c4117 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -650,26 +650,26 @@ static void do_pnp_card_entries(void *symval, unsigned long size,

device_id_check(mod->name, "pnp", size, id_size, symval);
DEF_FIELD_ADDR(symval, pnp_card_device_id, devs);
- typeof(devs) devs_last;
+ DEF_FIELD_ADDR_VAR(symval, pnp_card_device_id, devs, devs_aux);

for (i = 0; i < count; i++) {
unsigned int j;
- devs_last = devs + i * id_size;
+ devs_aux = devs + i * id_size;

for (j = 0; j < PNP_MAX_DEVICES; j++) {
- const char *id = (char *)(*devs_last)[j].id;
+ const char *id = (char *)(*devs_aux)[j].id;
int j2;
int dup = 0;

if (!id[0])
break;

- /* find duplicate, already added value */
- while ((devs_last -= id_size) >= devs && !dup) {
+ /* find duplicate on previous devs*/
+ while ((devs_aux -= id_size) >= devs && !dup) {

for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) {
const char *id2 =
- (char *)(*devs_last)[j2].id;
+ (char *)(*devs_aux)[j2].id;

if (!id2[0])
break;
--
2.19.1