Skip to content

Commit

Permalink
Kaveh Ghazi's printf format attribute checking patch.
Browse files Browse the repository at this point in the history
bfd:
	* elf32-xtensa.c (vsprint_msg): Add format attribute.  Fix
	format bugs.
	* vms.h (_bfd_vms_debug): Add format attribute.
	(_bfd_vms_debug, _bfd_hexdump): Fix typos.

binutils:
	* bucomm.h (report): Add format attribute.
	* dlltool.c (inform): Likewise.
	* dllwrap.c (display, inform, warn): Likewise.
	* objdump.c (objdump_sprintf): Likewise.
	* readelf.c (error, warn): Likewise.  Fix format bugs.

gas:
	* config/tc-tic30.c (debug): Add format attribute.  Fix format
	bugs.

include:
	* dis-asm.h (fprintf_ftype): Add format attribute.

opcodes:
	* arc-dis.c, arm-dis.c, cris-dis.c, crx-dis.c, d10v-dis.c,
	d30v-dis.c, fr30-dis.c, h8300-dis.c, h8500-dis.c, i860-dis.c,
	ia64-dis.c, ip2k-dis.c, m10200-dis.c, m10300-dis.c,
	m88k-dis.c, mcore-dis.c, mips-dis.c, ms1-dis.c, or32-dis.c,
	ppc-dis.c, sh64-dis.c, sparc-dis.c, tic4x-dis.c, tic80-dis.c,
	v850-dis.c: Fix format bugs.
	* ia64-gen.c (fail, warn): Add format attribute.
	* or32-opc.c (debug): Likewise.
  • Loading branch information
jim-wilson committed Jul 7, 2005
1 parent 0c7418a commit e0eda94
Show file tree
Hide file tree
Showing 41 changed files with 212 additions and 175 deletions.
7 changes: 7 additions & 0 deletions bfd/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2005-07-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>

* elf32-xtensa.c (vsprint_msg): Add format attribute. Fix
format bugs.
* vms.h (_bfd_vms_debug): Add format attribute.
(_bfd_vms_debug, _bfd_hexdump): Fix typos.

2005-07-07 H.J. Lu <hongjiu.lu@intel.com>

PR 975
Expand Down
4 changes: 2 additions & 2 deletions bfd/elf32-xtensa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ elf_xtensa_do_reloc (reloc_howto_type *howto,
}


static char *
static char * ATTRIBUTE_PRINTF(2,4)
vsprint_msg (const char *origmsg, const char *fmt, int arglen, ...)
{
/* To reduce the size of the memory leak,
Expand Down Expand Up @@ -2355,7 +2355,7 @@ elf_xtensa_relocate_section (bfd *output_bfd,
else
error_message = vsprint_msg (error_message, ": (%s+0x%x)",
strlen (name) + 22,
name, rel->r_addend);
name, (int)rel->r_addend);
}

if (!((*info->callbacks->reloc_dangerous)
Expand Down
4 changes: 2 additions & 2 deletions bfd/vms.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ struct vms_private_data_struct
#define SECTION_NAME_TEMPLATE "__SEC__%d"

#if VMS_DEBUG
extern void _bfd_vms_debug (int, char *, ..);
extern void _bfd_hexdump (int, unsignedchar *, int, int);
extern void _bfd_vms_debug (int, char *, ...) ATTRIBUTE_PRINTF_2;
extern void _bfd_hexdump (int, unsigned char *, int, int);

#define vms_debug _bfd_vms_debug
#endif
Expand Down
8 changes: 8 additions & 0 deletions binutils/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2005-07-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>

* bucomm.h (report): Add format attribute.
* dlltool.c (inform): Likewise.
* dllwrap.c (display, inform, warn): Likewise.
* objdump.c (objdump_sprintf): Likewise.
* readelf.c (error, warn): Likewise. Fix format bugs.

2005-07-05 Dmitry V. Levin <ldv@altlinux.org>
Nick Clifton <nickc@redhat.com>

Expand Down
2 changes: 1 addition & 1 deletion binutils/bucomm.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void bfd_nonfatal (const char *);

void bfd_fatal (const char *) ATTRIBUTE_NORETURN;

void report (const char *, va_list);
void report (const char *, va_list) ATTRIBUTE_PRINTF(1,0);

void fatal (const char *, ...) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;

Expand Down
2 changes: 1 addition & 1 deletion binutils/dlltool.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ static void fill_ordinals (export_type **);
static int alphafunc (const void *, const void *);
static void mangle_defs (void);
static void usage (FILE *, int);
static void inform (const char *, ...);
static void inform (const char *, ...) ATTRIBUTE_PRINTF_1;
static void set_dll_name_from_def (const char *);

static char *
Expand Down
6 changes: 3 additions & 3 deletions binutils/dllwrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ static int run (const char *, char *);
static char *mybasename (const char *);
static int strhash (const char *);
static void usage (FILE *, int);
static void display (const char *, va_list);
static void inform (const char *, ...);
static void warn (const char *, ...);
static void display (const char *, va_list) ATTRIBUTE_PRINTF(1,0);
static void inform (const char *, ...) ATTRIBUTE_PRINTF_1;
static void warn (const char *, ...) ATTRIBUTE_PRINTF_1;
static char *look_for_prog (const char *, const char *, int);
static char *deduce_name (const char *);
static void delete_temp_files (void);
Expand Down
2 changes: 1 addition & 1 deletion binutils/objdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ typedef struct

/* sprintf to a "stream". */

static int
static int ATTRIBUTE_PRINTF_2
objdump_sprintf (SFILE *f, const char *format, ...)
{
size_t n;
Expand Down
37 changes: 19 additions & 18 deletions binutils/readelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ static void (*byte_put) (unsigned char *, bfd_vma, int);
#define streq(a,b) (strcmp ((a), (b)) == 0)
#define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0)

static void
static void ATTRIBUTE_PRINTF_1
error (const char *message, ...)
{
va_list args;
Expand All @@ -275,7 +275,7 @@ error (const char *message, ...)
va_end (args);
}

static void
static void ATTRIBUTE_PRINTF_1
warn (const char *message, ...)
{
va_list args;
Expand Down Expand Up @@ -327,7 +327,7 @@ get_data (void *var, FILE *file, long offset, size_t size, size_t nmemb,

if (fseek (file, archive_file_offset + offset, SEEK_SET))
{
error (_("Unable to seek to 0x%x for %s\n"),
error (_("Unable to seek to 0x%lx for %s\n"),
archive_file_offset + offset, reason);
return NULL;
}
Expand All @@ -342,8 +342,8 @@ get_data (void *var, FILE *file, long offset, size_t size, size_t nmemb,

if (mvar == NULL)
{
error (_("Out of memory allocating 0x%x bytes for %s\n"),
size * nmemb, reason);
error (_("Out of memory allocating 0x%lx bytes for %s\n"),
(unsigned long)(size * nmemb), reason);
return NULL;
}

Expand All @@ -352,7 +352,8 @@ get_data (void *var, FILE *file, long offset, size_t size, size_t nmemb,

if (fread (mvar, size, nmemb, file) != nmemb)
{
error (_("Unable to read in 0x%x bytes of %s\n"), size * nmemb, reason);
error (_("Unable to read in 0x%lx bytes of %s\n"),
(unsigned long)(size * nmemb), reason);
if (mvar != var)
free (mvar);
return NULL;
Expand Down Expand Up @@ -7453,7 +7454,7 @@ fetch_indirect_string (unsigned long offset)

if (offset > debug_str_size)
{
warn (_("DW_FORM_strp offset too big: %x\n"), offset);
warn (_("DW_FORM_strp offset too big: %lx\n"), offset);
return _("<offset is too big>");
}

Expand Down Expand Up @@ -8464,7 +8465,7 @@ read_and_display_attr_value (unsigned long attribute,
break;

default:
warn (_("Unrecognized form: %d\n"), form);
warn (_("Unrecognized form: %lu\n"), form);
break;
}

Expand Down Expand Up @@ -9799,10 +9800,10 @@ display_debug_loc (Elf_Internal_Shdr *section,
{
if (start < next)
warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
start - section_begin, next - section_begin);
(long)(start - section_begin), (long)(next - section_begin));
else if (start > next)
warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
start - section_begin, next - section_begin);
(long)(start - section_begin), (long)(next - section_begin));
}
start = next;

Expand Down Expand Up @@ -10152,10 +10153,10 @@ display_debug_ranges (Elf_Internal_Shdr *section,
{
if (start < next)
warn (_("There is a hole [0x%lx - 0x%lx] in .debug_ranges section.\n"),
start - section_begin, next - section_begin);
(long)(start - section_begin), (long)(next - section_begin));
else if (start > next)
warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_ranges section.\n"),
start - section_begin, next - section_begin);
(long)(start - section_begin), (long)(next - section_begin));
}
start = next;

Expand Down Expand Up @@ -10528,7 +10529,7 @@ display_debug_frames (Elf_Internal_Shdr *section,

if (!cie)
{
warn ("Invalid CIE pointer %08lx in FDE at %08lx\n",
warn ("Invalid CIE pointer %08lx in FDE at %p\n",
cie_id, saved_start);
start = block_end;
fc->ncols = 0;
Expand Down Expand Up @@ -11814,9 +11815,9 @@ process_corefile_note_segment (FILE *file, bfd_vma offset, bfd_vma length)

if (((char *) next) > (((char *) pnotes) + length))
{
warn (_("corrupt note found at offset %x into core notes\n"),
((char *) external) - ((char *) pnotes));
warn (_(" type: %x, namesize: %08lx, descsize: %08lx\n"),
warn (_("corrupt note found at offset %lx into core notes\n"),
(long)((char *)external - (char *)pnotes));
warn (_(" type: %lx, namesize: %08lx, descsize: %08lx\n"),
inote.type, inote.namesz, inote.descsz);
break;
}
Expand Down Expand Up @@ -12295,7 +12296,7 @@ process_archive (char *file_name, FILE *file)
off = strtoul (arhdr.ar_name + 1, NULL, 10);
if (off >= longnames_size)
{
error (_("%s: invalid archive string table offset %lu\n"), off);
error (_("%s: invalid archive string table offset %lu\n"), file_name, off);
ret = 1;
break;
}
Expand All @@ -12311,7 +12312,7 @@ process_archive (char *file_name, FILE *file)

if (nameend == NULL)
{
error (_("%s: bad archive file name\n"));
error (_("%s: bad archive file name\n"), file_name);
ret = 1;
break;
}
Expand Down
5 changes: 5 additions & 0 deletions gas/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2005-07-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>

* config/tc-tic30.c (debug): Add format attribute. Fix format
bugs.

2005-07-06 H.J. Lu <hongjiu.lu@intel.com>

* config/tc-i386.c (cpu_arch): Add sse3.
Expand Down
24 changes: 12 additions & 12 deletions gas/config/tc-tic30.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const pseudo_typeS md_pseudo_table[] =
{0, 0, 0}
};

static int
static int ATTRIBUTE_PRINTF_1
debug (const char *string, ...)
{
if (flag_debug)
Expand Down Expand Up @@ -439,9 +439,9 @@ tic30_operand (char *token)

debug ("Expression type: %d\n",
current_op->direct.direct_expr.X_op);
debug ("Expression addnum: %d\n",
current_op->direct.direct_expr.X_add_number);
debug ("Segment: %d\n", retval);
debug ("Expression addnum: %ld\n",
(long) current_op->direct.direct_expr.X_add_number);
debug ("Segment: %p\n", retval);

input_line_pointer = save_input_line_pointer;

Expand Down Expand Up @@ -609,9 +609,9 @@ tic30_operand (char *token)
retval = expression (&current_op->immediate.imm_expr);
debug ("Expression type: %d\n",
current_op->immediate.imm_expr.X_op);
debug ("Expression addnum: %d\n",
current_op->immediate.imm_expr.X_add_number);
debug ("Segment: %d\n", retval);
debug ("Expression addnum: %ld\n",
(long) current_op->immediate.imm_expr.X_add_number);
debug ("Segment: %p\n", retval);
input_line_pointer = save_input_line_pointer;

if (current_op->immediate.imm_expr.X_op == O_constant)
Expand Down Expand Up @@ -1140,7 +1140,7 @@ md_apply_fix (fixS *fixP,
debug ("Values in fixP\n");
debug ("fx_size = %d\n", fixP->fx_size);
debug ("fx_pcrel = %d\n", fixP->fx_pcrel);
debug ("fx_where = %d\n", fixP->fx_where);
debug ("fx_where = %ld\n", fixP->fx_where);
debug ("fx_offset = %d\n", (int) fixP->fx_offset);
{
char *buf = fixP->fx_frag->fr_literal + fixP->fx_where;
Expand Down Expand Up @@ -1182,11 +1182,11 @@ md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
valueT
md_section_align (segT segment, valueT size)
{
debug ("In md_section_align() segment = %d and size = %d\n",
segment, size);
debug ("In md_section_align() segment = %p and size = %lu\n",
segment, (unsigned long) size);
size = (size + 3) / 4;
size *= 4;
debug ("New size value = %d\n", size);
debug ("New size value = %lu\n", (unsigned long) size);
return size;
}

Expand All @@ -1196,7 +1196,7 @@ md_pcrel_from (fixS *fixP)
int offset;

debug ("In md_pcrel_from()\n");
debug ("fx_where = %d\n", fixP->fx_where);
debug ("fx_where = %ld\n", fixP->fx_where);
debug ("fx_size = %d\n", fixP->fx_size);
/* Find the opcode that represents the current instruction in the
fr_literal storage area, and check bit 21. Bit 21 contains whether the
Expand Down
4 changes: 4 additions & 0 deletions include/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2005-07-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>

* dis-asm.h (fprintf_ftype): Add format attribute.

2005-07-03 Steve Ellcey <sje@cup.hp.com>

PR other/13906
Expand Down
2 changes: 1 addition & 1 deletion include/dis-asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern "C" {
#include <stdio.h>
#include "bfd.h"

typedef int (*fprintf_ftype) (void *, const char*, ...);
typedef int (*fprintf_ftype) (void *, const char*, ...) ATTRIBUTE_FPTR_PRINTF_2;

enum dis_insn_type {
dis_noninsn, /* Not a valid instruction */
Expand Down
11 changes: 11 additions & 0 deletions opcodes/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2005-07-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>

* arc-dis.c, arm-dis.c, cris-dis.c, crx-dis.c, d10v-dis.c,
d30v-dis.c, fr30-dis.c, h8300-dis.c, h8500-dis.c, i860-dis.c,
ia64-dis.c, ip2k-dis.c, m10200-dis.c, m10300-dis.c,
m88k-dis.c, mcore-dis.c, mips-dis.c, ms1-dis.c, or32-dis.c,
ppc-dis.c, sh64-dis.c, sparc-dis.c, tic4x-dis.c, tic80-dis.c,
v850-dis.c: Fix format bugs.
* ia64-gen.c (fail, warn): Add format attribute.
* or32-opc.c (debug): Likewise.

2005-07-07 Khem Raj <kraj@mvista.com>

* arm-dis.c (opcode32 arm_opcodes): Fix ARM VFP fadds instruction
Expand Down
2 changes: 1 addition & 1 deletion opcodes/arc-dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ decodeInstr (bfd_vma address, /* Address of this instruction. */
bytes = dsmOneArcInst (address, (void *)& s);

/* Display the disassembly instruction. */
(*func) (stream, "%08x ", s.words[0]);
(*func) (stream, "%08lx ", s.words[0]);
(*func) (stream, " ");
(*func) (stream, "%-10s ", s.instrBuffer);

Expand Down
Loading

0 comments on commit e0eda94

Please sign in to comment.