|
|
60918b |
From 2b5c925d19e1eeecf6a24809396fed2774ee0695 Mon Sep 17 00:00:00 2001
|
|
|
60918b |
From: Jean Delvare <jdelvare@suse.de>
|
|
|
60918b |
Date: Tue, 25 Jul 2017 11:21:30 +0200
|
|
|
60918b |
Subject: [PATCH 06/10] biosdecode: Avoid repeating pointer arithmetic
|
|
|
60918b |
|
|
|
60918b |
This makes the code both more efficient and more readable.
|
|
|
60918b |
|
|
|
60918b |
---
|
|
|
60918b |
biosdecode.c | 18 +++++++++---------
|
|
|
60918b |
1 file changed, 9 insertions(+), 9 deletions(-)
|
|
|
60918b |
|
|
|
60918b |
diff --git a/biosdecode.c b/biosdecode.c
|
|
|
60918b |
index b37e510..99a27fe 100644
|
|
|
60918b |
--- a/biosdecode.c
|
|
|
60918b |
+++ b/biosdecode.c
|
|
|
60918b |
@@ -375,7 +375,7 @@ static void pir_link_bitmap(char letter, const u8 *p)
|
|
|
60918b |
|
|
|
60918b |
static int pir_decode(const u8 *p, size_t len)
|
|
|
60918b |
{
|
|
|
60918b |
- int i;
|
|
|
60918b |
+ int i, n;
|
|
|
60918b |
|
|
|
60918b |
if (len < 32 || !checksum(p, WORD(p + 6)))
|
|
|
60918b |
return 0;
|
|
|
60918b |
@@ -394,18 +394,18 @@ static int pir_decode(const u8 *p, size_t len)
|
|
|
60918b |
printf("\tMiniport Data: 0x%08X\n",
|
|
|
60918b |
DWORD(p + 16));
|
|
|
60918b |
|
|
|
60918b |
- for (i = 1; i <= (WORD(p + 6) - 32) / 16; i++)
|
|
|
60918b |
+ n = (len - 32) / 16;
|
|
|
60918b |
+ for (i = 1, p += 32; i <= n; i++, p += 16)
|
|
|
60918b |
{
|
|
|
60918b |
- printf("\tDevice: %02x:%02x,",
|
|
|
60918b |
- p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
|
|
|
60918b |
- pir_slot_number(p[(i + 1) * 16 + 14]);
|
|
|
60918b |
+ printf("\tDevice: %02x:%02x,", p[0], p[1] >> 3);
|
|
|
60918b |
+ pir_slot_number(p[14]);
|
|
|
60918b |
printf("\n");
|
|
|
60918b |
if (opt.pir == PIR_FULL)
|
|
|
60918b |
{
|
|
|
60918b |
- pir_link_bitmap('A', p + (i + 1) * 16 + 2);
|
|
|
60918b |
- pir_link_bitmap('B', p + (i + 1) * 16 + 5);
|
|
|
60918b |
- pir_link_bitmap('C', p + (i + 1) * 16 + 8);
|
|
|
60918b |
- pir_link_bitmap('D', p + (i + 1) * 16 + 11);
|
|
|
60918b |
+ pir_link_bitmap('A', p + 2);
|
|
|
60918b |
+ pir_link_bitmap('B', p + 5);
|
|
|
60918b |
+ pir_link_bitmap('C', p + 8);
|
|
|
60918b |
+ pir_link_bitmap('D', p + 11);
|
|
|
60918b |
}
|
|
|
60918b |
}
|
|
|
60918b |
|
|
|
60918b |
--
|
|
|
60918b |
2.9.5
|
|
|
60918b |
|