Skip to contentSkip to conversation

tile: use ARRAY_SIZE

PATCH In review Himangi Saraogi 2 participants 2 messages Jun 16, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tile: use ARRAY_SIZE

ARRAY_SIZE is more concise to use when the size of an array is divided by the size of its type or the size of its first element.

The semantic patch that makes this change is as follows:

// <smpl>
@i@
@@

@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
// </smpl>

---
Not compile tested.

 arch/tile/kernel/traps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/tile/kernel/traps.c +1 -1
index f3ceb63..86900cc 100644
@@ -277,7 +277,7 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
 		if (fixup_exception(regs))  /* ILL_TRANS or UNALIGN_DATA */
 			return;
 		if (fault_num >= 0 &&
-		    fault_num < sizeof(int_name)/sizeof(int_name[0]) &&
+		    fault_num < ARRAY_SIZE(int_name) &&
 		    int_name[fault_num] != NULL)
 			name = int_name[fault_num];
 		else
Signature · 1 line
1.9.1
#1 lore raw
Quoted 18 lines · Himangi Saraogi

ARRAY_SIZE is more concise to use when the size of an array is divided by the size of its type or the size of its first element.

The semantic patch that makes this change is as follows:

// <smpl>
@i@
@@

@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
// </smpl>

Quoted 6 lines

---
Not compile tested.

  arch/tile/kernel/traps.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, taken into the tile tree.

Signature · 2 lines
Chris Metcalf, Tilera Corp.
http://www.tilera.com