bfd_set_input_error
A downside to the 2017-10-04 PR22245 fix is that bfd_set_error can now silently accept invalid errors if/when someone passes the a value of the wrong enumeration type, which previously would be caught by the -Wenum-conversion warning. PR 22245 * bfd.c (bfd_set_error): Revert 2017-10-04 change. Remove ellipsis parameter. Split out bfd_error_on_input code to.. (bfd_set_input_error): .. New function. * archive.c (_bfd_write_archive_contents): Use bfd_set_input_error. * vms-lib.c (_bfd_vms_lib_write_archive_contents): Likewise. * bfd-in2.h: Regenerate.
This commit is contained in:
parent
7d36e27991
commit
2ca7de3746
@ -1,3 +1,13 @@
|
||||
2017-10-05 Pedro Alves <palves@redhat.com>
|
||||
|
||||
PR 22245
|
||||
* bfd.c (bfd_set_error): Revert 2017-10-04 change. Remove
|
||||
ellipsis parameter. Split out bfd_error_on_input code to..
|
||||
(bfd_set_input_error): .. New function.
|
||||
* archive.c (_bfd_write_archive_contents): Use bfd_set_input_error.
|
||||
* vms-lib.c (_bfd_vms_lib_write_archive_contents): Likewise.
|
||||
* bfd-in2.h: Regenerate.
|
||||
|
||||
2017-10-05 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* elflink.c (elf_link_input_bfd): Correct ctor/dtor in init_array/
|
||||
|
@ -2309,7 +2309,7 @@ _bfd_write_archive_contents (bfd *arch)
|
||||
return TRUE;
|
||||
|
||||
input_err:
|
||||
bfd_set_error (bfd_error_on_input, current, bfd_get_error ());
|
||||
bfd_set_input_error (current, bfd_get_error ());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -7054,7 +7054,9 @@ bfd_error_type;
|
||||
|
||||
bfd_error_type bfd_get_error (void);
|
||||
|
||||
void bfd_set_error (int error_tag, ...);
|
||||
void bfd_set_error (bfd_error_type error_tag);
|
||||
|
||||
void bfd_set_input_error (bfd *input, bfd_error_type error_tag);
|
||||
|
||||
const char *bfd_errmsg (bfd_error_type error_tag);
|
||||
|
||||
|
49
bfd/bfd.c
49
bfd/bfd.c
@ -497,32 +497,47 @@ FUNCTION
|
||||
bfd_set_error
|
||||
|
||||
SYNOPSIS
|
||||
void bfd_set_error (int error_tag, ...);
|
||||
void bfd_set_error (bfd_error_type error_tag);
|
||||
|
||||
DESCRIPTION
|
||||
Set the BFD error condition to be @var{error_tag}.
|
||||
If @var{error_tag} is bfd_error_on_input, then this function
|
||||
takes two more parameters, the input bfd where the error
|
||||
occurred, and the bfd_error_type error.
|
||||
|
||||
@var{error_tag} must not be bfd_error_on_input. Use
|
||||
bfd_set_input_error for input errors instead.
|
||||
*/
|
||||
|
||||
void
|
||||
bfd_set_error (int error_tag, ...)
|
||||
bfd_set_error (bfd_error_type error_tag)
|
||||
{
|
||||
bfd_error = error_tag;
|
||||
if (error_tag == bfd_error_on_input)
|
||||
{
|
||||
/* This is an error that occurred during bfd_close when
|
||||
writing an archive, but on one of the input files. */
|
||||
va_list ap;
|
||||
if (bfd_error >= bfd_error_on_input)
|
||||
abort ();
|
||||
}
|
||||
|
||||
va_start (ap, error_tag);
|
||||
input_bfd = va_arg (ap, bfd *);
|
||||
input_error = (bfd_error_type) va_arg (ap, int);
|
||||
if (input_error >= bfd_error_on_input)
|
||||
abort ();
|
||||
va_end (ap);
|
||||
}
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_set_input_error
|
||||
|
||||
SYNOPSIS
|
||||
void bfd_set_input_error (bfd *input, bfd_error_type error_tag);
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Set the BFD error condition to be bfd_error_on_input.
|
||||
@var{input} is the input bfd where the error occurred, and
|
||||
@var{error_tag} the bfd_error_type error.
|
||||
*/
|
||||
|
||||
void
|
||||
bfd_set_input_error (bfd *input, bfd_error_type error_tag)
|
||||
{
|
||||
/* This is an error that occurred during bfd_close when writing an
|
||||
archive, but on one of the input files. */
|
||||
bfd_error = bfd_error_on_input;
|
||||
input_bfd = input;
|
||||
input_error = error_tag;
|
||||
if (input_error >= bfd_error_on_input)
|
||||
abort ();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2305,7 +2305,7 @@ _bfd_vms_lib_write_archive_contents (bfd *arch)
|
||||
return TRUE;
|
||||
|
||||
input_err:
|
||||
bfd_set_error (bfd_error_on_input, current, bfd_get_error ());
|
||||
bfd_set_input_error (current, bfd_get_error ());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user