From MAILER-DAEMON Sat Jul 01 09:14:10 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1dRIDu-0003n7-WB
	for mharc-dmidecode-devel@gnu.org; Sat, 01 Jul 2017 09:14:09 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46623)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <ryan@cavaliercoder.com>) id 1dRIDs-0003lZ-2d
	for dmidecode-devel@nongnu.org; Sat, 01 Jul 2017 09:14:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <ryan@cavaliercoder.com>) id 1dRIDq-0008DK-NS
	for dmidecode-devel@nongnu.org; Sat, 01 Jul 2017 09:14:03 -0400
Received: from mail-qk0-x229.google.com ([2607:f8b0:400d:c09::229]:33897)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <ryan@cavaliercoder.com>)
	id 1dRIDq-0008CS-Gp
	for dmidecode-devel@nongnu.org; Sat, 01 Jul 2017 09:14:02 -0400
Received: by mail-qk0-x229.google.com with SMTP id d78so118860993qkb.1
	for <dmidecode-devel@nongnu.org>; Sat, 01 Jul 2017 06:14:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=cavaliercoder-com.20150623.gappssmtp.com; s=20150623;
	h=from:mime-version:date:message-id:subject:to;
	bh=EifKlM27D/KSQJ0OvwyIg84yAj845DzYUY6ERqrAt/k=;
	b=BDKbtkPfOk5LOEWlhtmN5a2cRuGwfb53hbYvVLcsGdgl7f1Qy90N8n8pIl6PDSP0l1
	AcFfOPunXuRhPs9o8OTaPsSf2AqSkh9Ef1fERIqDlmldSZrgKZ/OQSMs3AA1iC0Ayax6
	wzMTRTIcAo4Sofmlv217YUSpx5jNHIWWPwRBXG3I3/BSuwdpgUV3i6zFW+7HYdyA4ZQj
	qkv35uheuW9w2wHCb1Xs8HCWKk372LrU+FF1Ro31pIJMjTI745erLoE+irpgqeUa8CXY
	zIdlKTjKNTKhb7sQsj0iYRTggWAiJu2VbPIxyfGcylRM/SngBhHMLjWUWrrxe3pM8fSg
	IYnQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:from:mime-version:date:message-id:subject:to;
	bh=EifKlM27D/KSQJ0OvwyIg84yAj845DzYUY6ERqrAt/k=;
	b=Ms/n6xgeDRruqV5uO38xvZZUOIwmk3wvSY35Dpuyj8qUjLhDOey/I0+TB+1uGyViT1
	7Y/POl8Vmx4Sds8cKHvEpqTCg9h36zDdm+1LlsC6Hu7JHtqA9vQT+o5Cx9IFF6SCxIfn
	jWDsP6gwtzmewID2Oah4U5Y/YnBv+r1oJ8MdbaCJFYsm3418UQD/hB1i9ULX2eIt9K5/
	sMHhNn9HdgMKDUkNsSkOrqG1JSjhOOwd2qly5e5xzcy2ECazrWiQOHaT42WFYOiOBDs2
	OXD7G7fQqDo1Hw1mKd6umfkPT8cyrbi2eauftq6Oz7ZxoyGueVjVpp2aw5skpO6z1lVW
	9s5A==
X-Gm-Message-State: AKS2vOwxBumYWk3LudKxDThAgKdZ4RXTdK/oeIzVOlDT3iGSPww9F87Q
	FvSmABx5KE1TpS72ZRFYeopluZWCWAtJoac=
X-Received: by 10.55.166.194 with SMTP id p185mr30296992qke.132.1498914840117; 
	Sat, 01 Jul 2017 06:14:00 -0700 (PDT)
Received: from 1058052472880 named unknown by gmailapi.google.com with
	HTTPREST; Sat, 1 Jul 2017 06:13:59 -0700
From: Ryan Armstrong <ryan@cavaliercoder.com>
X-Mailer: Airmail (390)
MIME-Version: 1.0
Date: Sat, 1 Jul 2017 06:13:59 -0700
Message-ID: <CADtg0A3GZuV5mkoesmsdr8xNX07bZR4L9z1YQhamadwSWXmPBg@mail.gmail.com>
To: dmidecode-devel@nongnu.org
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:400d:c09::229
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Content-Filtered-By: Mailman/MimeDel 2.1.21
Subject: [dmidecode] [PATCH] Added support for Apple macOS
X-BeenThere: dmidecode-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <dmidecode-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/dmidecode-devel>, 
	<mailto:dmidecode-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/dmidecode-devel/>
List-Post: <mailto:dmidecode-devel@nongnu.org>
List-Help: <mailto:dmidecode-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/dmidecode-devel>,
	<mailto:dmidecode-devel-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Sat, 01 Jul 2017 13:14:05 -0000

Hi dmidecode team,

As discussed with Jean Delvare on Linked-In, please see attached for
my patch to add support for macOS to dmidecode.

This patch has been distributed for some time now via
https://github.com/cavaliercoder/dmidecode-osx=C2=A0and homebrew. I have
however, tidied the patch a little in preparation for submitting it to
you.

A few notes concerning the change:

- compiler warnings from upstream code were suppressed on macOS with
`-Wno-constant-logical-operand`

=C2=A0=C2=A0dmidecode.c:4514:26: warning: use of logical '&&' with constant=
 operand

-=C2=A0ALIGNMENT_WORKAROUND was required also on macOS and so the
conditional was expanded to include __LP64__

- The call to CFRelease on 4814 throws 'Segmentation fault: 11' since
macOS 10.12, if=C2=A0the compiled binary is not signed with an Apple
developer profile

Thanks for your consideration. I=E2=80=99d be happy to adjust the patch to =
your liking.

Regards,

Ryan Armstrong

From MAILER-DAEMON Wed Jul 19 04:22:46 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1dXkFq-0006tL-1l
	for mharc-dmidecode-devel@gnu.org; Wed, 19 Jul 2017 04:22:46 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:54898)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1dXkFo-0006tB-Nc
	for dmidecode-devel@nongnu.org; Wed, 19 Jul 2017 04:22:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1dXkFm-00020k-2Q
	for dmidecode-devel@nongnu.org; Wed, 19 Jul 2017 04:22:44 -0400
Received: from mx2.suse.de ([195.135.220.15]:39522 helo=mx1.suse.de)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <jdelvare@suse.de>) id 1dXkFl-00020D-Qc
	for dmidecode-devel@nongnu.org; Wed, 19 Jul 2017 04:22:41 -0400
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254])
	by mx1.suse.de (Postfix) with ESMTP id 5D8B6AC03
	for <dmidecode-devel@nongnu.org>; Wed, 19 Jul 2017 08:22:39 +0000 (UTC)
Date: Wed, 19 Jul 2017 10:22:37 +0200
From: Jean Delvare <jdelvare@suse.de>
To: dmidecode-devel@nongnu.org
Message-ID: <20170719102237.7f93f05d@endymion>
Organization: SUSE Linux
X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 195.135.220.15
Subject: [dmidecode] [PATCH 0/3] biosdecode: Decode the PIR table
X-BeenThere: dmidecode-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <dmidecode-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/dmidecode-devel>, 
	<mailto:dmidecode-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/dmidecode-devel/>
List-Post: <mailto:dmidecode-devel@nongnu.org>
List-Help: <mailto:dmidecode-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/dmidecode-devel>,
	<mailto:dmidecode-devel-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Wed, 19 Jul 2017 08:22:45 -0000

As requested in feature #109339:
https://savannah.nongnu.org/support/index.php?109339

[1/3] biosdecode: Add option --pir full
[2/3] biosdecode: Clean up the PIR table output
[3/3] biosdecode: Avoid repating pointer arithmetics

-- 
Jean Delvare
SUSE L3 Support


From MAILER-DAEMON Wed Jul 19 04:23:30 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1dXkGY-00072N-Ll
	for mharc-dmidecode-devel@gnu.org; Wed, 19 Jul 2017 04:23:30 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:54985)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1dXkGV-00071z-SM
	for dmidecode-devel@nongnu.org; Wed, 19 Jul 2017 04:23:29 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1dXkGT-0002Fm-7f
	for dmidecode-devel@nongnu.org; Wed, 19 Jul 2017 04:23:27 -0400
Received: from mx2.suse.de ([195.135.220.15]:39556 helo=mx1.suse.de)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <jdelvare@suse.de>) id 1dXkGS-0002FK-Rv
	for dmidecode-devel@nongnu.org; Wed, 19 Jul 2017 04:23:25 -0400
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254])
	by mx1.suse.de (Postfix) with ESMTP id B1D8FAC2F
	for <dmidecode-devel@nongnu.org>; Wed, 19 Jul 2017 08:23:23 +0000 (UTC)
Date: Wed, 19 Jul 2017 10:23:22 +0200
From: Jean Delvare <jdelvare@suse.de>
To: dmidecode-devel@nongnu.org
Message-ID: <20170719102322.656f35d0@endymion>
In-Reply-To: <20170719102237.7f93f05d@endymion>
References: <20170719102237.7f93f05d@endymion>
Organization: SUSE Linux
X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 195.135.220.15
Subject: [dmidecode] [PATCH 1/3] biosdecode: Add option --pir full
X-BeenThere: dmidecode-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <dmidecode-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/dmidecode-devel>, 
	<mailto:dmidecode-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/dmidecode-devel/>
List-Post: <mailto:dmidecode-devel@nongnu.org>
List-Help: <mailto:dmidecode-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/dmidecode-devel>,
	<mailto:dmidecode-devel-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Wed, 19 Jul 2017 08:23:29 -0000

Add an option to decode the details of the PIR table.

This implements support request #109339:
https://savannah.nongnu.org/support/index.php?109339
---
 biosdecode.c     |   59 ++++++++++++++++++++++++++++++-------------------------
 man/biosdecode.8 |    3 ++
 2 files changed, 36 insertions(+), 26 deletions(-)

--- dmidecode.orig/biosdecode.c	2017-07-17 11:01:58.836719674 +0200
+++ dmidecode/biosdecode.c	2017-07-17 11:15:54.810625212 +0200
@@ -73,12 +73,16 @@ struct opt
 {
 	const char *devmem;
 	unsigned int flags;
+	unsigned char pir;
 };
 static struct opt opt;
 
 #define FLAG_VERSION            (1 << 0)
 #define FLAG_HELP               (1 << 1)
 
+#define PIR_SHORT               0
+#define PIR_FULL                1
+
 struct bios_entry {
 	const char *anchor;
 	size_t anchor_len; /* computed */
@@ -386,32 +390,29 @@ static int pir_decode(const u8 *p, size_
 			i, p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
 		pir_slot_number(p[(i + 1) * 16 + 14]);
 		printf("\n");
-/*		printf("\tSlot Entry %u\n", i);
-		printf("\t\tID: %02x:%02x\n",
-			p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
-		printf("\t\tLink Value for INTA#: %u\n",
-			p[(i + 1) * 16 + 2]);
-		printf("\t\tIRQ Bitmap for INTA#:");
-		pir_irqs(WORD(p + (i + 1) * 16 + 3));
-		printf("\n");
-		printf("\t\tLink Value for INTB#: %u\n",
-			p[(i + 1) * 16 + 5]);
-		printf("\t\tIRQ Bitmap for INTB#:");
-		pir_irqs(WORD(p + (i + 1) * 16 + 6));
-		printf("\n");
-		printf("\t\tLink Value for INTC#: %u\n",
-			p[(i + 1) * 16 + 8]);
-		printf("\t\tIRQ Bitmap for INTC#:");
-		pir_irqs(WORD(p + (i + 1) * 16 + 9));
-		printf("\n");
-		printf("\t\tLink Value for INTD#: %u\n",
-			p[(i + 1) * 16 + 11]);
-		printf("\t\tIRQ Bitmap for INTD#:");
-		pir_irqs(WORD(p + (i + 1) * 16 + 12));
-		printf("\n");
-		printf("\t\tSlot Number:");
-		pir_slot_number(p[(i + 1) * 16 + 14]);
-		printf("\n");*/
+		if (opt.pir == PIR_FULL)
+		{
+			printf("\t\tLink Value for INTA#: %u\n",
+				p[(i + 1) * 16 + 2]);
+			printf("\t\tIRQ Bitmap for INTA#:");
+			pir_irqs(WORD(p + (i + 1) * 16 + 3));
+			printf("\n");
+			printf("\t\tLink Value for INTB#: %u\n",
+				p[(i + 1) * 16 + 5]);
+			printf("\t\tIRQ Bitmap for INTB#:");
+			pir_irqs(WORD(p + (i + 1) * 16 + 6));
+			printf("\n");
+			printf("\t\tLink Value for INTC#: %u\n",
+				p[(i + 1) * 16 + 8]);
+			printf("\t\tIRQ Bitmap for INTC#:");
+			pir_irqs(WORD(p + (i + 1) * 16 + 9));
+			printf("\n");
+			printf("\t\tLink Value for INTD#: %u\n",
+				p[(i + 1) * 16 + 11]);
+			printf("\t\tIRQ Bitmap for INTD#:");
+			pir_irqs(WORD(p + (i + 1) * 16 + 12));
+			printf("\n");
+		}
 	}
 
 	return 1;
@@ -616,6 +617,7 @@ static int parse_command_line(int argc,
 	const char *optstring = "d:hV";
 	struct option longopts[] = {
 		{ "dev-mem", required_argument, NULL, 'd' },
+		{ "pir", required_argument, NULL, 'P' },
 		{ "help", no_argument, NULL, 'h' },
 		{ "version", no_argument, NULL, 'V' },
 		{ NULL, 0, NULL, 0 }
@@ -627,6 +629,10 @@ static int parse_command_line(int argc,
 			case 'd':
 				opt.devmem = optarg;
 				break;
+			case 'P':
+				if (strcmp(optarg, "full") == 0)
+					opt.pir = PIR_FULL;
+				break;
 			case 'h':
 				opt.flags |= FLAG_HELP;
 				break;
@@ -646,6 +652,7 @@ static void print_help(void)
 		"Usage: biosdecode [OPTIONS]\n"
 		"Options are:\n"
 		" -d, --dev-mem FILE     Read memory from device FILE (default: " DEFAULT_MEM_DEV ")\n"
+		"     --pir full         Decode the details of the PCI IRQ routing table\n"
 		" -h, --help             Display this help text and exit\n"
 		" -V, --version          Display the version and exit\n";
 
--- dmidecode.orig/man/biosdecode.8	2017-07-17 11:01:58.836719674 +0200
+++ dmidecode/man/biosdecode.8	2017-07-17 11:02:03.478781694 +0200
@@ -60,6 +60,9 @@ program.
 .BR "-d" ", " "--dev-mem FILE"
 Read memory from device \fBFILE\fR (default: \fB/dev/mem\fR)
 .TP
+.BR "  " "  " "--pir full"
+Decode the details of the PCI IRQ routing table
+.TP
 .BR "-h" ", " "--help"
 Display usage information and exit
 .TP

-- 
Jean Delvare
SUSE L3 Support


From MAILER-DAEMON Wed Jul 19 04:24:07 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1dXkH9-0007SW-Qx
	for mharc-dmidecode-devel@gnu.org; Wed, 19 Jul 2017 04:24:07 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55063)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1dXkH6-0007SI-Vg
	for dmidecode-devel@nongnu.org; Wed, 19 Jul 2017 04:24:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1dXkH4-0002Vz-AV
	for dmidecode-devel@nongnu.org; Wed, 19 Jul 2017 04:24:04 -0400
Received: from mx2.suse.de ([195.135.220.15]:39597 helo=mx1.suse.de)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <jdelvare@suse.de>) id 1dXkH4-0002UC-3h
	for dmidecode-devel@nongnu.org; Wed, 19 Jul 2017 04:24:02 -0400
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254])
	by mx1.suse.de (Postfix) with ESMTP id F2351AAB6
	for <dmidecode-devel@nongnu.org>; Wed, 19 Jul 2017 08:24:00 +0000 (UTC)
Date: Wed, 19 Jul 2017 10:23:59 +0200
From: Jean Delvare <jdelvare@suse.de>
To: dmidecode-devel@nongnu.org
Message-ID: <20170719102359.22b9cc65@endymion>
In-Reply-To: <20170719102237.7f93f05d@endymion>
References: <20170719102237.7f93f05d@endymion>
Organization: SUSE Linux
X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 195.135.220.15
Subject: [dmidecode] [PATCH 2/3] biosdecode: Clean up the PIR table output
X-BeenThere: dmidecode-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <dmidecode-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/dmidecode-devel>, 
	<mailto:dmidecode-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/dmidecode-devel/>
List-Post: <mailto:dmidecode-devel@nongnu.org>
List-Help: <mailto:dmidecode-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/dmidecode-devel>,
	<mailto:dmidecode-devel-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Wed, 19 Jul 2017 08:24:06 -0000

* Remove entry numbers.
* Use "Device" instead of "ID".
* Put repeated code in a function.
* Don't display unconnected links.
* Shorten "slot number" to just "slot".
---
 biosdecode.c |   42 ++++++++++++++++++------------------------
 1 file changed, 18 insertions(+), 24 deletions(-)

--- dmidecode.orig/biosdecode.c	2017-07-17 11:15:54.810625212 +0200
+++ dmidecode/biosdecode.c	2017-07-17 12:09:56.855050306 +0200
@@ -355,7 +355,7 @@ static void pir_slot_number(u8 code)
 	if (code == 0)
 		printf(" on-board");
 	else
-		printf(" slot number %u", code);
+		printf(" slot %u", code);
 }
 
 static size_t pir_length(const u8 *p)
@@ -363,6 +363,16 @@ static size_t pir_length(const u8 *p)
 	return WORD(p + 6);
 }
 
+static void pir_link_bitmap(char letter, const u8 *p)
+{
+	if (p[0] == 0) /* Not connected */
+		return;
+
+	printf("\t\tINT%c#: Link 0x%02x, IRQ Bitmap", letter, p[0]);
+	pir_irqs(WORD(p + 1));
+	printf("\n");
+}
+
 static int pir_decode(const u8 *p, size_t len)
 {
 	int i;
@@ -372,7 +382,7 @@ static int pir_decode(const u8 *p, size_
 
 	printf("PCI Interrupt Routing %u.%u present.\n",
 		p[5], p[4]);
-	printf("\tRouter ID: %02x:%02x.%1x\n",
+	printf("\tRouter Device: %02x:%02x.%1x\n",
 		p[8], p[9]>>3, p[9] & 0x07);
 	printf("\tExclusive IRQs:");
 	pir_irqs(WORD(p + 10));
@@ -386,32 +396,16 @@ static int pir_decode(const u8 *p, size_
 
 	for (i = 1; i <= (WORD(p + 6) - 32) / 16; i++)
 	{
-		printf("\tSlot Entry %u: ID %02x:%02x,",
-			i, p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
+		printf("\tDevice: %02x:%02x,",
+			p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
 		pir_slot_number(p[(i + 1) * 16 + 14]);
 		printf("\n");
 		if (opt.pir == PIR_FULL)
 		{
-			printf("\t\tLink Value for INTA#: %u\n",
-				p[(i + 1) * 16 + 2]);
-			printf("\t\tIRQ Bitmap for INTA#:");
-			pir_irqs(WORD(p + (i + 1) * 16 + 3));
-			printf("\n");
-			printf("\t\tLink Value for INTB#: %u\n",
-				p[(i + 1) * 16 + 5]);
-			printf("\t\tIRQ Bitmap for INTB#:");
-			pir_irqs(WORD(p + (i + 1) * 16 + 6));
-			printf("\n");
-			printf("\t\tLink Value for INTC#: %u\n",
-				p[(i + 1) * 16 + 8]);
-			printf("\t\tIRQ Bitmap for INTC#:");
-			pir_irqs(WORD(p + (i + 1) * 16 + 9));
-			printf("\n");
-			printf("\t\tLink Value for INTD#: %u\n",
-				p[(i + 1) * 16 + 11]);
-			printf("\t\tIRQ Bitmap for INTD#:");
-			pir_irqs(WORD(p + (i + 1) * 16 + 12));
-			printf("\n");
+			pir_link_bitmap('A', p + (i + 1) * 16 + 2);
+			pir_link_bitmap('B', p + (i + 1) * 16 + 5);
+			pir_link_bitmap('C', p + (i + 1) * 16 + 8);
+			pir_link_bitmap('D', p + (i + 1) * 16 + 11);
 		}
 	}
 

-- 
Jean Delvare
SUSE L3 Support


From MAILER-DAEMON Wed Jul 19 04:26:57 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1dXkJt-0007nv-H7
	for mharc-dmidecode-devel@gnu.org; Wed, 19 Jul 2017 04:26:57 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55298)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1dXkJr-0007nm-8m
	for dmidecode-devel@nongnu.org; Wed, 19 Jul 2017 04:26:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1dXkJo-0003f7-Ff
	for dmidecode-devel@nongnu.org; Wed, 19 Jul 2017 04:26:55 -0400
Received: from mx2.suse.de ([195.135.220.15]:39752 helo=mx1.suse.de)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <jdelvare@suse.de>) id 1dXkJo-0003eq-8J
	for dmidecode-devel@nongnu.org; Wed, 19 Jul 2017 04:26:52 -0400
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254])
	by mx1.suse.de (Postfix) with ESMTP id 2363FAAB6
	for <dmidecode-devel@nongnu.org>; Wed, 19 Jul 2017 08:26:51 +0000 (UTC)
Date: Wed, 19 Jul 2017 10:26:49 +0200
From: Jean Delvare <jdelvare@suse.de>
To: dmidecode-devel@nongnu.org
Message-ID: <20170719102649.161fdff4@endymion>
In-Reply-To: <20170719102237.7f93f05d@endymion>
References: <20170719102237.7f93f05d@endymion>
Organization: SUSE Linux
X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 195.135.220.15
Subject: [dmidecode] [PATCH 3/3] biosdecode: Avoid repeating pointer
 arithmetic
X-BeenThere: dmidecode-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <dmidecode-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/dmidecode-devel>, 
	<mailto:dmidecode-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/dmidecode-devel/>
List-Post: <mailto:dmidecode-devel@nongnu.org>
List-Help: <mailto:dmidecode-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/dmidecode-devel>,
	<mailto:dmidecode-devel-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Wed, 19 Jul 2017 08:26:56 -0000

This makes the code both more efficient and more readable.
---
 biosdecode.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

--- dmidecode.orig/biosdecode.c	2017-07-17 11:16:06.510774783 +0200
+++ dmidecode/biosdecode.c	2017-07-17 11:16:19.897945953 +0200
@@ -375,7 +375,7 @@ static void pir_link_bitmap(char letter,
 
 static int pir_decode(const u8 *p, size_t len)
 {
-	int i;
+	int i, n;
 
 	if (len < 32 || !checksum(p, WORD(p + 6)))
 		return 0;
@@ -394,18 +394,18 @@ static int pir_decode(const u8 *p, size_
 		printf("\tMiniport Data: 0x%08X\n",
 			DWORD(p + 16));
 
-	for (i = 1; i <= (WORD(p + 6) - 32) / 16; i++)
+	n = (len - 32) / 16;
+	for (i = 1, p += 32; i <= n; i++, p += 16)
 	{
-		printf("\tDevice: %02x:%02x,",
-			p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
-		pir_slot_number(p[(i + 1) * 16 + 14]);
+		printf("\tDevice: %02x:%02x,", p[0], p[1] >> 3);
+		pir_slot_number(p[14]);
 		printf("\n");
 		if (opt.pir == PIR_FULL)
 		{
-			pir_link_bitmap('A', p + (i + 1) * 16 + 2);
-			pir_link_bitmap('B', p + (i + 1) * 16 + 5);
-			pir_link_bitmap('C', p + (i + 1) * 16 + 8);
-			pir_link_bitmap('D', p + (i + 1) * 16 + 11);
+			pir_link_bitmap('A', p + 2);
+			pir_link_bitmap('B', p + 5);
+			pir_link_bitmap('C', p + 8);
+			pir_link_bitmap('D', p + 11);
 		}
 	}
 

-- 
Jean Delvare
SUSE L3 Support


