public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:master commit in: misc/elf-abi/
Date: Tue,  6 Jan 2015 21:43:21 +0000 (UTC)	[thread overview]
Message-ID: <1420580651.666190ea1a94474f73c3e5efcb271432152c6767.blueness@gentoo> (raw)

commit:     666190ea1a94474f73c3e5efcb271432152c6767
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  6 21:44:11 2015 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Tue Jan  6 21:44:11 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=666190ea

misc/elf-abi.c: cleanup comments

---
 misc/elf-abi/elf-abi.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/misc/elf-abi/elf-abi.c b/misc/elf-abi/elf-abi.c
index 3be6aae..81e5e16 100644
--- a/misc/elf-abi/elf-abi.c
+++ b/misc/elf-abi/elf-abi.c
@@ -78,13 +78,12 @@
 #define EM_PPC		20		/* ppc */
 #define EM_PPC64	21		/* ppc64 */
 #define EM_S390		22		/* s390 */
-#define EM_SH		42		/* Hitachi SH */
-#define EM_SPARC32PLUS	18		/* sparc 32-bit */
-#define EM_SPARCV9	43		/* sparc 64-bit */
+#define EM_SH		42		/* sh */
+#define EM_SPARC32PLUS	18		/* sparc (32-bit) */
+#define EM_SPARCV9	43		/* sparc (64-bit) */
 #define EM_386		3		/* x86 */
 #define EM_X86_64	62		/* amd64 */
 
-/* The arm and mips ABI flags housed in e_flags */
 #define EF_MIPS_ABI2		0x00000020	/* Mask for mips n32 ABI */
 #define EF_ARM_EABIMASK		0XFF000000	/* Mask for arm EABI - we dont' destinguish versions */
 
@@ -218,9 +217,12 @@ read_endian(int fd, size_t count, int endian)
 	uint8_t data;
 	uint64_t value = 0;
 
+	if (count > 8)
+		errx(1, "Max width exceeded in read_endian()");
+
 	for(i = 0; i < count; i++) {
 		if (read(fd, &data, 1) == -1)
-			errx(1, "read() ei_class failed");
+			errx(1, "read() in read_endian() failed");
 		if (endian)
 			value += data << 8 * (count-i-1);
 		else
@@ -243,7 +245,6 @@ main(int argc, char* argv[])
 	char magic[4];			/* magic number at the begining of the file		*/
 	uint8_t ei_class;		/* ei_class is one byte of e_ident[]			*/
 	uint8_t ei_data;		/* ei_data is one byte of e_ident[]			*/
-
 	uint16_t e_machine;		/* Size is Elf32_Half or Elf64_Half.  Both are 2 bytes.	*/
 	uint32_t e_flags;		/* Size is Elf32_Word or Elf64_Word.  Both are 4 bytes.	*/
 	uint64_t e_machine_offset, e_flags_offset;  /* Wide enough for either 32 or 64 bits.	*/
@@ -261,7 +262,7 @@ main(int argc, char* argv[])
 		errx(1, "failed to open %s", argv[1]);
 	if (read(fd, magic, 4) == -1)
 		errx(1, "read() magic failed");
-	if (strncmp(magic, ELFMAG, 4) != 0)
+	if (strncmp(magic, ELFMAG, 4))
 		errx(1, "%s is not an ELF object", argv[1]);
 
 	/* 32 or 64 bits machine word size? */


             reply	other threads:[~2015-01-06 21:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-06 21:43 Anthony G. Basile [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-01-06 21:34 [gentoo-commits] proj/elfix:master commit in: misc/elf-abi/ Anthony G. Basile
2015-01-06 20:47 Anthony G. Basile
2015-01-06 18:22 Anthony G. Basile
2015-01-06 17:26 Anthony G. Basile
2015-01-06 15:13 Anthony G. Basile
2015-01-05 16:26 Anthony G. Basile
2015-01-05 16:23 Anthony G. Basile
2015-01-03 23:53 Anthony G. Basile
2015-01-03 23:49 Anthony G. Basile
2015-01-03 23:19 Anthony G. Basile

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1420580651.666190ea1a94474f73c3e5efcb271432152c6767.blueness@gentoo \
    --to=blueness@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox