avoid printing the latest error message if some ldd method worked.

This commit is contained in:
mrg 2023-01-04 03:33:54 +00:00
parent d49186a20d
commit eec0208311
1 changed files with 16 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ldd.c,v 1.27 2022/10/18 19:04:57 mrg Exp $ */ /* $NetBSD: ldd.c,v 1.28 2023/01/04 03:33:54 mrg Exp $ */
/*- /*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -62,7 +62,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID("$NetBSD: ldd.c,v 1.27 2022/10/18 19:04:57 mrg Exp $"); __RCSID("$NetBSD: ldd.c,v 1.28 2023/01/04 03:33:54 mrg Exp $");
#endif /* not lint */ #endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
@ -124,7 +124,7 @@ main(int argc, char **argv)
const char *fmt1 = NULL, *fmt2 = NULL; const char *fmt1 = NULL, *fmt2 = NULL;
int c, exit_status = EXIT_SUCCESS; int c, exit_status = EXIT_SUCCESS;
char cwd[MAXPATHLEN], path[MAXPATHLEN]; char cwd[MAXPATHLEN], path[MAXPATHLEN];
bool verbose = false, failed = false; bool verbose = false;
#ifdef DEBUG #ifdef DEBUG
debug = 1; debug = 1;
@ -164,6 +164,7 @@ main(int argc, char **argv)
for (; argc != 0; argc--, argv++) { for (; argc != 0; argc--, argv++) {
int fd; int fd;
bool failed = false;
if (**argv != '/') { if (**argv != '/') {
strcpy(path, cwd); strcpy(path, cwd);
@ -185,17 +186,20 @@ main(int argc, char **argv)
} }
/* Alpha never had 32 bit support. */ /* Alpha never had 32 bit support. */
#if (defined(_LP64) && !defined(ELF64_ONLY)) || defined(MIPS_N32) #if (defined(_LP64) && !defined(ELF64_ONLY)) || defined(MIPS_N32)
if (failed && elf32_ldd(fd, *argv, path, fmt1, fmt2) == -1) { if (failed) {
if (elf32_ldd(fd, *argv, path, fmt1, fmt2) == -1) {
if (verbose) if (verbose)
warnx("%s", error_message); warnx("%s", error_message);
failed = true; } else
failed = false;
} }
#if defined(__mips__) && 0 /* XXX this is still hosed for some reason */ #if defined(__mips__) && 0 /* XXX this is still hosed for some reason */
if (failed && if (failed) {
elf32_ldd_compat(fd, *argv, path, fmt1, fmt2) == -1) { if (elf32_ldd_compat(fd, *argv, path, fmt1, fmt2) == -1) {
if (verbose) if (verbose)
warnx("%s", error_message); warnx("%s", error_message);
failed = true; } else
failed = false;
} }
#endif #endif
#endif #endif