Hi Michael,

On Thu, Oct 10, 2024 at 10:27:31AM +0000, Michael Pratt wrote:
> In many source files, putc() and fputc() and putchar()
> are used interchangeably, and puts() and fputs() and printf()
> are used interchangeably.
> 
> Reducing the usage to 2 of the 3 both reduces binary size
> of the final product, improves readability and searchability
> of the code, especially since grepping for puts() can clash with
> words like "inputs" and "outputs", and that putc() can be a macro
> while fputc() is the safer function.

Aha. I should have read the whole series first before asking questions
on some of the previous commits. So this is why you (already) tried to
replace putchar_unlocked with fputc.

If we are trying to be more consistent then I think I would prefer we
use putchar, puts and printf, instead of adding stdout to all these
calls.

Cheers,

Mark

> While at it, adjust spacing syntax and punctuation for consistency.
> 
> Signed-off-by: Michael Pratt <mcpr...@pm.me>
> ---
>  libcpu/i386_disasm.c          |   2 +-
>  src/addr2line.c               |   8 +--
>  src/ar.c                      |   2 +-
>  src/elfclassify.c             |   2 +-
>  src/elflint.c                 |   2 +-
>  src/nm.c                      |   2 +-
>  src/objdump.c                 |   4 +-
>  src/readelf.c                 | 108 +++++++++++++++++-----------------
>  src/unstrip.c                 |   2 +-
>  tests/addrcfi.c               |   2 +-
>  tests/addrscopes.c            |   2 +-
>  tests/all-dwarf-ranges.c      |   4 +-
>  tests/arextract.c             |   4 +-
>  tests/asm-tst1.c              |   6 +-
>  tests/asm-tst2.c              |   6 +-
>  tests/asm-tst3.c              |   8 +--
>  tests/asm-tst4.c              |   2 +-
>  tests/asm-tst5.c              |   2 +-
>  tests/asm-tst6.c              |   2 +-
>  tests/asm-tst7.c              |   6 +-
>  tests/asm-tst8.c              |   6 +-
>  tests/asm-tst9.c              |   6 +-
>  tests/buildid.c               |   4 +-
>  tests/debugaltlink.c          |   4 +-
>  tests/dwarf-getmacros.c       |   6 +-
>  tests/dwarf-getstring.c       |   2 +-
>  tests/dwarf-ranges.c          |   2 +-
>  tests/dwarfcfi.c              |   2 +-
>  tests/dwflmodtest.c           |   6 +-
>  tests/funcretval.c            |   6 +-
>  tests/funcscopes.c            |   2 +-
>  tests/get-aranges.c           |   6 +-
>  tests/get-files-define-file.c |   2 +-
>  tests/get-files.c             |   2 +-
>  tests/get-pubnames.c          |   4 +-
>  tests/line2addr.c             |   4 +-
>  tests/next-files.c            |   2 +-
>  tests/saridx.c                |   2 +-
>  tests/scnnames.c              |   2 +-
>  tests/sectiondump.c           |   4 +-
>  tests/show-die-info.c         |  62 +++++++++----------
>  tests/showptable.c            |   2 +-
>  tests/test-nlist.c            |   2 +-
>  43 files changed, 159 insertions(+), 157 deletions(-)
> 
> diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c
> index dec62bfa..7f199b49 100644
> --- a/libcpu/i386_disasm.c
> +++ b/libcpu/i386_disasm.c
> @@ -565,7 +565,7 @@ i386_disasm (Ebl *ebl __attribute__((unused)),
>  #endif
>               default:
>                 /* Cannot happen.  */
> -               puts ("unknown prefix");
> +               fputs ("unknown prefix\n", stdout);
>                 abort ();
>               }
>             data = begin + 1;
> diff --git a/src/addr2line.c b/src/addr2line.c
> index d87e5b45..9ced8a62 100644
> --- a/src/addr2line.c
> +++ b/src/addr2line.c
> @@ -729,10 +729,10 @@ handle_address (const char *string, Dwfl *dwfl)
>         show_int (&dwarf_lineisa, info, "isa");
>         show_int (&dwarf_linediscriminator, info, "discriminator");
>       }
> -      putchar ('\n');
> +      fputc ('\n', stdout);
>      }
>    else
> -    puts ("??:0");
> +    fputs ("??:0\n", stdout);
>  
>    if (show_inlines)
>      {
> @@ -811,10 +811,10 @@ handle_address (const char *string, Dwfl *dwfl)
>                     if (src != NULL)
>                       {
>                         print_src (src, lineno, linecol, &cu);
> -                       putchar ('\n');
> +                       fputc ('\n', stdout);
>                       }
>                     else
> -                     puts ("??:0");
> +                     fputs ("??:0\n", stdout);
>                   }
>               }
>           }
> diff --git a/src/ar.c b/src/ar.c
> index 9ace28b9..ad48c395 100644
> --- a/src/ar.c
> +++ b/src/ar.c
> @@ -579,7 +579,7 @@ do_oper_extract (int oper, const char *arfname, char 
> **argv, int argc,
>         if (oper == oper_list)
>           {
>             if (!verbose)
> -             puts (arhdr->ar_name);
> +             printf ("%s\n", arhdr->ar_name);
>  
>             goto next;
>           }
> diff --git a/src/elfclassify.c b/src/elfclassify.c
> index 25fe9a65..8c18b5d1 100644
> --- a/src/elfclassify.c
> +++ b/src/elfclassify.c
> @@ -820,7 +820,7 @@ process_current_path (int *status)
>      {
>      case do_print:
>        if (checks_passed == flag_print_matching)
> -        puts (current_path);
> +        printf ("%s\n", current_path);
>        break;
>      case do_print0:
>        if (checks_passed == flag_print_matching)
> diff --git a/src/elflint.c b/src/elflint.c
> index cdc6108d..24f3c043 100644
> --- a/src/elflint.c
> +++ b/src/elflint.c
> @@ -181,7 +181,7 @@ main (int argc, char *argv[])
>                  elf_errmsg (-1));
>  
>         if (prev_error_count == error_count && !be_quiet)
> -         puts (_("No errors"));
> +         fputs (_("No errors\n"), stdout);
>       }
>  
>        close (fd);
> diff --git a/src/nm.c b/src/nm.c
> index 06f1a072..40270c9d 100644
> --- a/src/nm.c
> +++ b/src/nm.c
> @@ -1125,7 +1125,7 @@ show_symbols_posix (Elf *elf, const GElf_Ehdr *ehdr, 
> GElf_Word strndx,
>                   : " %0*" PRIo64 " %0*" PRIo64)),
>               digits, syms[cnt].sym.st_value,
>               digits, syms[cnt].sym.st_size);
> -      putchar ('\n');
> +      fputc ('\n', stdout);
>      }
>  
>  #ifdef USE_DEMANGLE
> diff --git a/src/objdump.c b/src/objdump.c
> index e081db64..3b6b10cd 100644
> --- a/src/objdump.c
> +++ b/src/objdump.c
> @@ -392,7 +392,7 @@ show_relocs_x (Ebl *ebl, GElf_Shdr *shdr, Elf_Data 
> *symdata,
>       }
>        printf ("%c%#" PRIx64, sign, r_addend);
>      }
> -  putchar ('\n');
> +  fputc ('\n', stdout);
>  }
>  
>  
> @@ -537,7 +537,7 @@ show_relocs (Ebl *ebl, const char *fname, uint32_t 
> shstrndx)
>           show_relocs_rela (ebl, shdr, data, symdata, xndxdata,
>                             symshdr->sh_link, shstrndx);
>  
> -       putchar ('\n');
> +       fputc ('\n', stdout);
>       }
>      }
>  
> diff --git a/src/readelf.c b/src/readelf.c
> index a524a64b..c9437b79 100644
> --- a/src/readelf.c
> +++ b/src/readelf.c
> @@ -1112,14 +1112,15 @@ print_file_type (unsigned short int e_type)
>       N_("DYN (Shared object file)"),
>       N_("CORE (Core file)")
>        };
> -      puts (_(knowntypes[e_type]));
> +      fputs (_(knowntypes[e_type]), stdout);
> +      fputc ('\n', stdout);
>      }
>    else if (e_type >= ET_LOOS && e_type <= ET_HIOS)
>      printf (_("OS Specific: (%x)\n"),  e_type);
>    else if (e_type >= ET_LOPROC /* && e_type <= ET_HIPROC always true */)
>      printf (_("Processor Specific: (%x)\n"),  e_type);
>    else
> -    puts ("???");
> +    fputs ("???\n", stdout);
>  }
>  
>  
> @@ -1299,19 +1300,19 @@ There are %zd section headers, starting at offset %#" 
> PRIx64 ":\n\
>      error_exit (0, _("cannot get section header string table index: %s"),
>               elf_errmsg (-1));
>  
> -  puts (_("Section Headers:"));
> +  fputs (_("Section Headers:\n"), stdout);
>  
>    if (ehdr->e_ident[EI_CLASS] == ELFCLASS32)
> -    puts (_("[Nr] Name                 Type         Addr     Off    Size   
> ES Flags Lk Inf Al"));
> +    fputs (_("[Nr] Name                 Type         Addr     Off    Size   
> ES Flags Lk Inf Al\n"), stdout);
>    else
> -    puts (_("[Nr] Name                 Type         Addr             Off     
>  Size     ES Flags Lk Inf Al"));
> +    fputs (_("[Nr] Name                 Type         Addr             Off    
>   Size     ES Flags Lk Inf Al\n"), stdout);
>  
>    if (print_decompress)
>      {
>        if (ehdr->e_ident[EI_CLASS] == ELFCLASS32)
> -     puts (_("     [Compression  Size   Al]"));
> +     fputs (_("     [Compression  Size   Al]\n"), stdout);
>        else
> -     puts (_("     [Compression  Size     Al]"));
> +     fputs (_("     [Compression  Size     Al]\n"), stdout);
>      }
>  
>    for (cnt = 0; cnt < shnum; ++cnt)
> @@ -1418,13 +1419,13 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr)
>      /* No program header, this is OK in relocatable objects.  */
>      return;
>  
> -  puts (_("Program Headers:"));
> +  fputs (_("Program Headers:\n"), stdout);
>    if (ehdr->e_ident[EI_CLASS] == ELFCLASS32)
> -    puts (_("\
> -  Type           Offset   VirtAddr   PhysAddr   FileSiz  MemSiz   Flg 
> Align"));
> +    fputs (_("\
> +  Type           Offset   VirtAddr   PhysAddr   FileSiz  MemSiz   Flg 
> Align\n"), stdout);
>    else
> -    puts (_("\
> -  Type           Offset   VirtAddr           PhysAddr           FileSiz  
> MemSiz   Flg Align"));
> +    fputs (_("\
> +  Type           Offset   VirtAddr           PhysAddr           FileSiz  
> MemSiz   Flg Align\n"), stdout);
>  
>    /* Process all program headers.  */
>    bool has_relro = false;
> @@ -1439,7 +1440,7 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr)
>        /* If for some reason the header cannot be returned show this.  */
>        if (unlikely (phdr == NULL))
>       {
> -       puts ("  ???");
> +       fputs ("  ???\n", stdout);
>         continue;
>       }
>  
> @@ -1505,7 +1506,7 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr)
>    if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
>      error_exit (0, _("cannot get section header string table index"));
>  
> -  puts (_("\n Section to Segment mapping:\n  Segment Sections..."));
> +  fputs (_("\n Section to Segment mapping:\n  Segment Sections...\n"), 
> stdout);
>  
>    for (size_t cnt = 0; cnt < phnum; ++cnt)
>      {
> @@ -2003,7 +2004,8 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr 
> *shdr, GElf_Phdr *phdr)
>       case DT_PLTREL:;
>         const char *tagname = ebl_dynamic_tag_name (ebl, dyn->d_un.d_val,
>                                                     NULL, 0);
> -       puts (tagname ?: "???");
> +       fputs (tagname ?: "???", stdout);
> +       fputc ('\n', stdout);
>         break;
>  
>       case DT_FLAGS:
> @@ -3968,8 +3970,8 @@ print_liblist (Ebl *ebl)
>         if (data == NULL)
>           return;
>  
> -       puts (_("\
> -       Library                       Time Stamp          Checksum Version 
> Flags"));
> +       fputs (_("\
> +       Library                       Time Stamp          Checksum Version 
> Flags\n"), stdout);
>  
>         for (int cnt = 0; cnt < nentries; ++cnt)
>           {
> @@ -4769,7 +4771,7 @@ static void
>  print_block (size_t n, const void *block)
>  {
>    if (n == 0)
> -    puts (_("empty block"));
> +    fputs (_("empty block\n"), stdout);
>    else
>      {
>        printf (_("%zu byte block:"), n);
> @@ -4777,7 +4779,7 @@ print_block (size_t n, const void *block)
>        do
>       printf (" %02x", *data++);
>        while (--n > 0);
> -      putchar ('\n');
> +      fputc ('\n', stdout);
>      }
>  }
>  
> @@ -6633,7 +6635,7 @@ print_debug_ranges_section (Dwfl_Module *dwflmod,
>           printf (" [%6tx] ", offset);
>         else
>           printf ("          ");
> -       puts (_("base address"));
> +       fputs (_("base address\n"), stdout);
>         printf ("          ");
>         print_dwarf_addr (dwflmod, address_size, end, end);
>         printf ("\n");
> @@ -6781,7 +6783,7 @@ print_cfa_program (const unsigned char *readp, const 
> unsigned char *const endp,
>  {
>    char regnamebuf[REGNAMESZ];
>  
> -  puts ("\n   Program:");
> +  fputs ("\n   Program:\n", stdout);
>    Dwarf_Word pc = vma_base;
>    while (readp < endp)
>      {
> @@ -6797,7 +6799,7 @@ print_cfa_program (const unsigned char *readp, const 
> unsigned char *const endp,
>           int64_t sop2;
>  
>         case DW_CFA_nop:
> -         puts ("     nop");
> +         fputs ("     nop\n", stdout);
>           break;
>         case DW_CFA_set_loc:
>           if ((uint64_t) (endp - readp) < 1)
> @@ -6871,10 +6873,10 @@ print_cfa_program (const unsigned char *readp, const 
> unsigned char *const endp,
>                   regname (ebl, op2, regnamebuf));
>           break;
>         case DW_CFA_remember_state:
> -         puts ("     remember_state");
> +         fputs ("     remember_state\n", stdout);
>           break;
>         case DW_CFA_restore_state:
> -         puts ("     restore_state");
> +         fputs ("     restore_state\n", stdout);
>           break;
>         case DW_CFA_def_cfa:
>           if ((uint64_t) (endp - readp) < 1)
> @@ -7000,9 +7002,9 @@ print_cfa_program (const unsigned char *readp, const 
> unsigned char *const endp,
>           break;
>         case DW_CFA_GNU_window_save:  /* DW_CFA_AARCH64_negate_ra_state  */
>           if (ehdr->e_machine == EM_AARCH64)
> -           puts ("     AARCH64_negate_ra_state");
> +           fputs ("     AARCH64_negate_ra_state\n", stdout);
>           else
> -           puts ("     GNU_window_save");
> +           fputs ("     GNU_window_save\n", stdout);
>           break;
>         case DW_CFA_GNU_args_size:
>           if ((uint64_t) (endp - readp) < 1)
> @@ -7128,7 +7130,7 @@ print_encoding_base (const char *pfx, unsigned int 
> fde_encoding)
>    printf ("(%s", pfx);
>  
>    if (fde_encoding == DW_EH_PE_omit)
> -    puts ("omit)");
> +    fputs ("omit)\n", stdout);
>    else
>      {
>        unsigned int w = fde_encoding;
> @@ -7146,7 +7148,7 @@ print_encoding_base (const char *pfx, unsigned int 
> fde_encoding)
>        if (w != 0)
>       printf ("%s%x", w != fde_encoding ? " " : "", w);
>  
> -      puts (")");
> +      fputs (")\n", stdout);
>      }
>  }
>  
> @@ -7380,9 +7382,9 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl 
> *ebl, GElf_Ehdr *ehdr,
>                     while (++startp < readp)
>                       printf ("%#x ", *startp);
>  
> -                   putchar ('(');
> +                   fputc ('(', stdout);
>                     print_encoding (encoding);
> -                   putchar (' ');
> +                   fputc (' ', stdout);
>                     switch (encoding & 0xf)
>                       {
>                       case DW_EH_PE_sleb128:
> @@ -7428,7 +7430,7 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl 
> *ebl, GElf_Ehdr *ehdr,
>             cie = cie->next;
>         if (unlikely (cie == NULL))
>           {
> -           puts ("invalid CIE reference in FDE");
> +           fputs ("invalid CIE reference in FDE\n", stdout);
>             return;
>           }
>  
> @@ -7485,7 +7487,7 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl 
> *ebl, GElf_Ehdr *ehdr,
>                   & (ptr_size == 4
>                      ? UINT64_C (0xffffffff)
>                      : UINT64_C (0xffffffffffffffff)));
> -       putchar ('\n');
> +       fputc ('\n', stdout);
>  
>         if (cie->augmentation[0] == 'z')
>           {
> @@ -8163,7 +8165,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
>             || (form != DW_FORM_data16
>                 && attrp->cu->version < 4)) /* blocks were expressions.  */
>           {
> -           putchar ('\n');
> +           fputc ('\n', stdout);
>             print_ops (cbargs->dwflmod, cbargs->dbg,
>                        12 + level * 2, 12 + level * 2,
>                        cbargs->version, cbargs->addrsize, cbargs->offset_size,
> @@ -8175,7 +8177,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
>  
>       case DW_AT_discr_list:
>         if (block.length == 0)
> -         puts ("<default>");
> +         fputs ("<default>\n", stdout);
>         else if (form != DW_FORM_data16)
>           {
>             const unsigned char *readp = block.data;
> @@ -8257,7 +8259,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
>                 if (readp < readendp)
>                   printf (", ");
>               }
> -           putchar ('\n');
> +           fputc ('\n', stdout);
>           }
>         else
>           print_block (block.length, block.data);
> @@ -9146,7 +9148,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl 
> *ebl, GElf_Ehdr *ehdr,
>  
>        Dwarf_Off str_offsets_base = str_offsets_base_off (dbg, NULL);
>  
> -      puts (_("\nDirectory table:"));
> +      fputs (_("\nDirectory table:\n"), stdout);
>        if (version > 4)
>       {
>         struct encpair { uint16_t desc; uint16_t form; };
> @@ -9223,7 +9225,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl 
> *ebl, GElf_Ehdr *ehdr,
>        if (unlikely (linep >= lineendp))
>       goto invalid_unit;
>  
> -      puts (_("\nFile name table:"));
> +      fputs (_("\nFile name table:\n"), stdout);
>        if (version > 4)
>       {
>         struct encpair { uint16_t desc; uint16_t form; };
> @@ -9284,7 +9286,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl 
> *ebl, GElf_Ehdr *ehdr,
>       }
>        else
>       {
> -       puts (_(" Entry Dir   Time      Size      Name"));
> +       fputs (_(" Entry Dir   Time      Size      Name\n"), stdout);
>         for (unsigned int cnt = 1; linep < lineendp && *linep != 0; ++cnt)
>           {
>             /* First comes the file name.  */
> @@ -9330,11 +9332,11 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl 
> *ebl, GElf_Ehdr *ehdr,
>  
>        if (linep == lineendp)
>       {
> -       puts (_("\nNo line number statements."));
> +       fputs (_("\nNo line number statements\n"), stdout);
>         continue;
>       }
>  
> -      puts (_("\nLine number statements:"));
> +      fputs (_("\nLine number statements:\n"), stdout);
>        Dwarf_Word address = 0;
>        unsigned int op_index = 0;
>        size_t line = 1;
> @@ -9413,7 +9415,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl 
> *ebl, GElf_Ehdr *ehdr,
>             switch (opcode)
>               {
>               case DW_LNE_end_sequence:
> -               puts (_(" end of sequence"));
> +               fputs (_(" end of sequence\n"), stdout);
>  
>                 /* Reset the registers we care about.  */
>                 address = 0;
> @@ -9531,7 +9533,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl 
> *ebl, GElf_Ehdr *ehdr,
>  
>               default:
>                 /* Unknown, ignore it.  */
> -               puts (_(" unknown opcode"));
> +               fputs (_(" unknown opcode\n"), stdout);
>                 linep += len - 1;
>                 break;
>               }
> @@ -9543,7 +9545,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl 
> *ebl, GElf_Ehdr *ehdr,
>               {
>               case DW_LNS_copy:
>                 /* Takes no argument.  */
> -               puts (_(" copy"));
> +               fputs (_(" copy\n"), stdout);
>                 break;
>  
>               case DW_LNS_advance_pc:
> @@ -9604,7 +9606,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl 
> *ebl, GElf_Ehdr *ehdr,
>  
>               case DW_LNS_set_basic_block:
>                 /* Takes no argument.  */
> -               puts (_(" set basic block flag"));
> +               fputs (_(" set basic block flag\n"), stdout);
>                 break;
>  
>               case DW_LNS_const_add_pc:
> @@ -9645,12 +9647,12 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl 
> *ebl, GElf_Ehdr *ehdr,
>  
>               case DW_LNS_set_prologue_end:
>                 /* Takes no argument.  */
> -               puts (_(" set prologue end flag"));
> +               fputs (_(" set prologue end flag\n"), stdout);
>                 break;
>  
>               case DW_LNS_set_epilogue_begin:
>                 /* Takes no argument.  */
> -               puts (_(" set epilogue begin flag"));
> +               fputs (_(" set epilogue begin flag\n"), stdout);
>                 break;
>  
>               case DW_LNS_set_isa:
> @@ -10343,7 +10345,7 @@ print_debug_loc_section (Dwfl_Module *dwflmod,
>           printf (" [%6tx] ", offset);
>         else
>           printf ("          ");
> -       puts (_("base address"));
> +       fputs (_("base address\n"), stdout);
>         printf ("          ");
>         print_dwarf_addr (dwflmod, address_size, end, end);
>         printf ("\n");
> @@ -11282,7 +11284,7 @@ print_debug_frame_hdr_section (Dwfl_Module *dwflmod 
> __attribute__ ((unused)),
>    if (fde_count == 0 || table_enc == DW_EH_PE_omit)
>      return;
>  
> -  puts (" Table:");
> +  fputs (" Table:\n", stdout);
>  
>    /* Optimize for the most common case.  */
>    if (table_enc == (DW_EH_PE_datarel | DW_EH_PE_sdata4))
> @@ -11383,7 +11385,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod 
> __attribute__ ((unused)),
>    while (readp < action_table)
>      {
>        if (u == 0)
> -     puts (_("\n Call site table:"));
> +     fputs (_("\n Call site table:\n"), stdout);
>  
>        uint64_t call_site_start;
>        readp = read_encoded (call_site_encoding, readp, dataend,
> @@ -11411,7 +11413,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod 
> __attribute__ ((unused)),
>    unsigned int max_ar_filter = 0;
>    if (max_action > 0)
>      {
> -      puts ("\n Action table:");
> +      fputs ("\n Action table:\n", stdout);
>  
>        size_t maxdata = (size_t) (dataend - action_table);
>        if (max_action > maxdata || maxdata - max_action < 1)
> @@ -11442,7 +11444,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod 
> __attribute__ ((unused)),
>         if (abs (ar_disp) & 1)
>           printf (" -> [%4u]\n", u + (ar_disp + 1) / 2);
>         else if (ar_disp != 0)
> -         puts (" -> ???");
> +         fputs (" -> ???\n", stdout);
>         else
>           fputc ('\n', stdout);
>         ++u;
> @@ -11453,7 +11455,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod 
> __attribute__ ((unused)),
>    if (max_ar_filter > 0 && ttype_base != NULL)
>      {
>        unsigned char dsize;
> -      puts ("\n TType table:");
> +      fputs ("\n TType table:\n", stdout);
>  
>        // XXX Not *4, size of encoding;
>        switch (ttype_encoding & 7)
> @@ -13284,7 +13286,7 @@ hex_dump (const uint8_t *data, size_t len)
>         printf ("%c", isprint (b) ? b : '.');
>       }
>  
> -      putchar ('\n');
> +      fputc ('\n', stdout);
>        pos += chunk;
>      }
>  }
> diff --git a/src/unstrip.c b/src/unstrip.c
> index d70053de..3307c4c0 100644
> --- a/src/unstrip.c
> +++ b/src/unstrip.c
> @@ -2489,7 +2489,7 @@ list_module (Dwfl_Module *mod)
>       printf ("@%#" PRIx64, id_vaddr);
>      }
>    else
> -    putchar ('-');
> +    fputc ('-', stdout);
>  
>    printf (" %s %s %s\n",
>         file ?: have_elf ? "." : "-",
> diff --git a/tests/addrcfi.c b/tests/addrcfi.c
> index 2b7d7bd0..2a77db27 100644
> --- a/tests/addrcfi.c
> +++ b/tests/addrcfi.c
> @@ -69,7 +69,7 @@ print_detail (int result, const Dwarf_Op *ops, size_t nops, 
> Dwarf_Addr bias)
>           printf ("(%" PRId64 ",%" PRId64 ")",
>                   ops[i].number, ops[i].number2);
>       }
> -      puts ("");
> +      fputc ('\n', stdout);
>      }
>  }
>  
> diff --git a/tests/addrscopes.c b/tests/addrscopes.c
> index b231b6a9..01eb6e4e 100644
> --- a/tests/addrscopes.c
> +++ b/tests/addrscopes.c
> @@ -130,7 +130,7 @@ handle_address (GElf_Addr pc, Dwfl *dwfl)
>             if (highpc != lowpc)
>               paddr (" .. ", highpc - 1, hiline == loline ? NULL : hiline);
>           }
> -       puts ("");
> +       fputc ('\n', stdout);
>  
>         print_vars (indent + INDENT, die);
>       }
> diff --git a/tests/all-dwarf-ranges.c b/tests/all-dwarf-ranges.c
> index 4331a05b..0980d0e0 100644
> --- a/tests/all-dwarf-ranges.c
> +++ b/tests/all-dwarf-ranges.c
> @@ -33,7 +33,7 @@ ranges_die (Dwarf_Die *die)
>    Dwarf_Addr base, start, end;
>    int ranges = dwarf_ranges (die, 0, &base, &start, &end);
>    if (ranges < 0)
> -    puts (dwarf_errmsg (-1));
> +    printf ("%s\n", dwarf_errmsg (-1));
>    else if (ranges > 0)
>      {
>        printf ("die: %s (%x)\n", dwarf_diename (die) ?: "<unknown>",
> @@ -42,7 +42,7 @@ ranges_die (Dwarf_Die *die)
>          (off = dwarf_ranges (die, off, &base, &start, &end)); )
>       if (off == -1)
>         {
> -         puts (dwarf_errmsg (-1));
> +         printf ("%s\n", dwarf_errmsg (-1));
>           break;
>         }
>       else
> diff --git a/tests/arextract.c b/tests/arextract.c
> index 936d7f55..c8cb19e2 100644
> --- a/tests/arextract.c
> +++ b/tests/arextract.c
> @@ -113,7 +113,7 @@ Failed to get base address for the archive element: %s\n",
>  
>             if (write (outfd, buf, n) != n)
>               {
> -               puts ("Writing output failed");
> +               fputs ("Writing output failed\n", stdout);
>                 exit (1);
>               }
>  
> @@ -124,7 +124,7 @@ Failed to get base address for the archive element: %s\n",
>         /* Check whether all the date was read and written out.  */
>         if (todo != 0)
>           {
> -           puts ("Reading archive member failed.");
> +           fputs ("Reading archive member failed\n", stdout);
>             exit (1);
>           }
>  
> diff --git a/tests/asm-tst1.c b/tests/asm-tst1.c
> index d03a4361..3d845dbf 100644
> --- a/tests/asm-tst1.c
> +++ b/tests/asm-tst1.c
> @@ -78,7 +78,7 @@ main (void)
>    Ebl *ebl = ebl_openbackend_machine (EM_386);
>    if (ebl == NULL)
>      {
> -      puts ("cannot open backend library");
> +      fputs ("cannot open backend library\n", stdout);
>        return 1;
>      }
>  
> @@ -132,7 +132,7 @@ main (void)
>      }
>    if (elf_kind (elf) != ELF_K_ELF)
>      {
> -      puts ("not a valid ELF file");
> +      fputs ("not a valid ELF file\n", stdout);
>        result = 1;
>        goto out_close2;
>      }
> @@ -147,7 +147,7 @@ main (void)
>  
>    if (memcmp (ehdr, &expected_ehdr, sizeof (GElf_Ehdr)) != 0)
>      {
> -      puts ("ELF header does not match");
> +      fputs ("ELF header does not match\n", stdout);
>        result = 1;
>        goto out_close2;
>      }
> diff --git a/tests/asm-tst2.c b/tests/asm-tst2.c
> index e65a9d2f..de65a15a 100644
> --- a/tests/asm-tst2.c
> +++ b/tests/asm-tst2.c
> @@ -77,7 +77,7 @@ main (void)
>    Ebl *ebl = ebl_openbackend_machine (EM_386);
>    if (ebl == NULL)
>      {
> -      puts ("cannot open backend library");
> +      fputs ("cannot open backend library\n", stdout);
>        return 1;
>      }
>  
> @@ -148,7 +148,7 @@ main (void)
>      }
>    if (elf_kind (elf) != ELF_K_ELF)
>      {
> -      puts ("not a valid ELF file");
> +      fputs ("not a valid ELF file\n", stdout);
>        result = 1;
>        goto out_close2;
>      }
> @@ -163,7 +163,7 @@ main (void)
>  
>    if (memcmp (ehdr, &expected_ehdr, sizeof (GElf_Ehdr)) != 0)
>      {
> -      puts ("ELF header does not match");
> +      fputs ("ELF header does not match\n", stdout);
>        result = 1;
>        goto out_close2;
>      }
> diff --git a/tests/asm-tst3.c b/tests/asm-tst3.c
> index e45fa16a..2775207d 100644
> --- a/tests/asm-tst3.c
> +++ b/tests/asm-tst3.c
> @@ -69,7 +69,7 @@ main (void)
>    Ebl *ebl = ebl_openbackend_machine (EM_386);
>    if (ebl == NULL)
>      {
> -      puts ("cannot open backend library");
> +      fputs ("cannot open backend library\n", stdout);
>        return 1;
>      }
>  
> @@ -155,7 +155,7 @@ main (void)
>      }
>    if (elf_kind (elf) != ELF_K_ELF)
>      {
> -      puts ("not a valid ELF file");
> +      fputs ("not a valid ELF file\n", stdout);
>        result = 1;
>        goto out_close2;
>      }
> @@ -225,14 +225,14 @@ main (void)
>  
>         if (shdr->sh_link != 2)
>           {
> -           puts ("symbol table has incorrect link");
> +           fputs ("symbol table has incorrect link\n", stdout);
>             result = 1;
>           }
>  
>         data = elf_getdata (scn, NULL);
>         if (data == NULL)
>           {
> -           puts ("cannot get data of symbol table");
> +           fputs ("cannot get data of symbol table\n", stdout);
>             result = 1;
>           }
>         else
> diff --git a/tests/asm-tst4.c b/tests/asm-tst4.c
> index 1a05bfcc..ffec28ba 100644
> --- a/tests/asm-tst4.c
> +++ b/tests/asm-tst4.c
> @@ -45,7 +45,7 @@ main (void)
>    Ebl *ebl = ebl_openbackend_machine (EM_386);
>    if (ebl == NULL)
>      {
> -      puts ("cannot open backend library");
> +      fputs ("cannot open backend library\n", stdout);
>        return 1;
>      }
>  
> diff --git a/tests/asm-tst5.c b/tests/asm-tst5.c
> index 256873f0..00bb9824 100644
> --- a/tests/asm-tst5.c
> +++ b/tests/asm-tst5.c
> @@ -47,7 +47,7 @@ main (void)
>    Ebl *ebl = ebl_openbackend_machine (EM_386);
>    if (ebl == NULL)
>      {
> -      puts ("cannot open backend library");
> +      fputs ("cannot open backend library\n", stdout);
>        return 1;
>      }
>  
> diff --git a/tests/asm-tst6.c b/tests/asm-tst6.c
> index 4a665ed0..9e19ef85 100644
> --- a/tests/asm-tst6.c
> +++ b/tests/asm-tst6.c
> @@ -45,7 +45,7 @@ main (void)
>    Ebl *ebl = ebl_openbackend_machine (EM_386);
>    if (ebl == NULL)
>      {
> -      puts ("cannot open backend library");
> +      fputs ("cannot open backend library\n", stdout);
>        return 1;
>      }
>  
> diff --git a/tests/asm-tst7.c b/tests/asm-tst7.c
> index 87c21485..ca16e97e 100644
> --- a/tests/asm-tst7.c
> +++ b/tests/asm-tst7.c
> @@ -45,7 +45,7 @@ main (void)
>    Ebl *ebl = ebl_openbackend_machine (EM_386);
>    if (ebl == NULL)
>      {
> -      puts ("cannot open backend library");
> +      fputs ("cannot open backend library\n", stdout);
>        return 1;
>      }
>  
> @@ -89,7 +89,7 @@ main (void)
>      }
>    if (elf_kind (elf) != ELF_K_ELF)
>      {
> -      puts ("not a valid ELF file");
> +      fputs ("not a valid ELF file\n", stdout);
>        result = 1;
>        goto out_close2;
>      }
> @@ -129,7 +129,7 @@ main (void)
>  
>         if (cnt > 1)
>           {
> -           puts ("too many symbol");
> +           fputs ("too many symbols\n", stdout);
>             result = 1;
>             break;
>           }
> diff --git a/tests/asm-tst8.c b/tests/asm-tst8.c
> index 7dbac10f..f367135b 100644
> --- a/tests/asm-tst8.c
> +++ b/tests/asm-tst8.c
> @@ -45,7 +45,7 @@ main (void)
>    Ebl *ebl = ebl_openbackend_machine (EM_386);
>    if (ebl == NULL)
>      {
> -      puts ("cannot open backend library");
> +      fputs ("cannot open backend library\n", stdout);
>        return 1;
>      }
>  
> @@ -90,7 +90,7 @@ main (void)
>      }
>    if (elf_kind (elf) != ELF_K_ELF)
>      {
> -      puts ("not a valid ELF file");
> +      fputs ("not a valid ELF file\n", stdout);
>        result = 1;
>        goto out_close2;
>      }
> @@ -130,7 +130,7 @@ main (void)
>  
>         if (cnt > 1)
>           {
> -           puts ("too many symbol");
> +           fputs ("too many symbols\n", stdout);
>             result = 1;
>             break;
>           }
> diff --git a/tests/asm-tst9.c b/tests/asm-tst9.c
> index 6bec3f6e..4bba6d11 100644
> --- a/tests/asm-tst9.c
> +++ b/tests/asm-tst9.c
> @@ -97,7 +97,7 @@ main (void)
>    Ebl *ebl = ebl_openbackend_machine (EM_386);
>    if (ebl == NULL)
>      {
> -      puts ("cannot open backend library");
> +      fputs ("cannot open backend library\n", stdout);
>        return 1;
>      }
>  
> @@ -182,7 +182,7 @@ main (void)
>      }
>    if (elf_kind (elf) != ELF_K_ELF)
>      {
> -      puts ("not a valid ELF file");
> +      fputs ("not a valid ELF file\n", stdout);
>        result = 1;
>        goto out_close2;
>      }
> @@ -197,7 +197,7 @@ main (void)
>  
>    if (memcmp (ehdr, &expected_ehdr, sizeof (GElf_Ehdr)) != 0)
>      {
> -      puts ("ELF header does not match");
> +      fputs ("ELF header does not match\n", stdout);
>        result = 1;
>        goto out_close2;
>      }
> diff --git a/tests/buildid.c b/tests/buildid.c
> index 2390eff7..bbc51b96 100644
> --- a/tests/buildid.c
> +++ b/tests/buildid.c
> @@ -69,8 +69,8 @@ main (int argc, char *argv[])
>         const unsigned char *p = build_id;
>         const unsigned char *end = p + len;
>         while (p < end)
> -           printf("%02x", (unsigned)*p++);
> -       putchar('\n');
> +           printf ("%02x", (unsigned)*p++);
> +       fputc ('\n', stdout);
>       }
>  
>        elf_end (elf);
> diff --git a/tests/debugaltlink.c b/tests/debugaltlink.c
> index e7dc8623..763b897a 100644
> --- a/tests/debugaltlink.c
> +++ b/tests/debugaltlink.c
> @@ -71,8 +71,8 @@ main (int argc, char *argv[])
>         const unsigned char *p = build_id;
>         const unsigned char *end = p + ret;
>         while (p < end)
> -           printf("%02x", (unsigned)*p++);
> -       putchar('\n');
> +           printf ("%02x", (unsigned)*p++);
> +       fputc ('\n', stdout);
>       }
>  
>        dwarf_end (dwarf);
> diff --git a/tests/dwarf-getmacros.c b/tests/dwarf-getmacros.c
> index 8381d42c..57f36041 100644
> --- a/tests/dwarf-getmacros.c
> +++ b/tests/dwarf-getmacros.c
> @@ -116,7 +116,7 @@ include (Dwarf *dbg, Dwarf_Off macoff, ptrdiff_t token)
>    while ((token = dwarf_getmacros_off (dbg, macoff, mac, dbg, token)) != 0)
>      if (token == -1)
>        {
> -     puts (dwarf_errmsg (dwarf_errno ()));
> +     printf ("%s\n", dwarf_errmsg (dwarf_errno ()));
>       break;
>        }
>  }
> @@ -128,7 +128,7 @@ getmacros (Dwarf *dbg, Dwarf_Die *die, bool new_style)
>         (off = dwarf_getmacros (die, mac, dbg, off)); )
>      if (off == -1)
>        {
> -     puts (dwarf_errmsg (-1));
> +     printf ("%s\n", dwarf_errmsg (-1));
>       break;
>        }
>  }
> @@ -167,7 +167,7 @@ main (int argc, char *argv[])
>        Dwarf_Die cudie_mem, *cudie = dwarf_offdie (dbg, cuoff, &cudie_mem);
>        if (cudie == NULL)
>       {
> -       puts (dwarf_errmsg (-1));
> +       printf ("%s\n", dwarf_errmsg (-1));
>         return 1;
>       }
>        getmacros (dbg, cudie, new_style);
> diff --git a/tests/dwarf-getstring.c b/tests/dwarf-getstring.c
> index ffa3e375..d2689807 100644
> --- a/tests/dwarf-getstring.c
> +++ b/tests/dwarf-getstring.c
> @@ -64,7 +64,7 @@ main (int argc, char *argv[])
>        for (int i = 0; i < 100; ++i)
>       {
>         str = dwarf_getstring (dbg, offset, &len);
> -       puts (str);
> +       printf ("%s\n", str);
>  
>         /* Advance.  */
>         offset += len + 1;
> diff --git a/tests/dwarf-ranges.c b/tests/dwarf-ranges.c
> index 4bcf96ce..a2406461 100644
> --- a/tests/dwarf-ranges.c
> +++ b/tests/dwarf-ranges.c
> @@ -44,7 +44,7 @@ main (int argc, char *argv[])
>         (off = dwarf_ranges (cudie, off, &base, &start, &end)); )
>      if (off == -1)
>        {
> -     puts (dwarf_errmsg (dwarf_errno ()));
> +     printf ("%s\n", dwarf_errmsg (dwarf_errno ()));
>       break;
>        }
>      else
> diff --git a/tests/dwarfcfi.c b/tests/dwarfcfi.c
> index 29849e71..d59e7e1f 100644
> --- a/tests/dwarfcfi.c
> +++ b/tests/dwarfcfi.c
> @@ -72,7 +72,7 @@ print_detail (int result, const Dwarf_Op *ops, size_t nops)
>           printf ("(%" PRId64 ",%" PRId64 ")",
>                   ops[i].number, ops[i].number2);
>       }
> -      puts ("");
> +      fputc ('\n', stdout);
>      }
>  }
>  
> diff --git a/tests/dwflmodtest.c b/tests/dwflmodtest.c
> index bec8a07c..29a6d70b 100644
> --- a/tests/dwflmodtest.c
> +++ b/tests/dwflmodtest.c
> @@ -97,7 +97,7 @@ print_instance (Dwarf_Die *instance, void *arg)
>    if (entry != (Dwarf_Addr) -1)
>      printf (" => %#" PRIx64 "\n", entry);
>    else
> -    puts ("");
> +    fputc ('\n', stdout);
>  
>    return DWARF_CB_OK;
>  }
> @@ -123,7 +123,7 @@ print_func (Dwarf_Die *func, void *arg)
>  
>    if (dwarf_func_inline (func))
>      {
> -      puts (" inline function");
> +      fputs (" inline function\n", stdout);
>        if (show_inlines)
>       print_inline (func, arg);
>      }
> @@ -148,7 +148,7 @@ print_func (Dwarf_Die *func, void *arg)
>       printf (" %#" PRIx64 "..%#" PRIx64 " => %#" PRIx64 "\n",
>               lo, hi, entry);
>        else
> -     puts ("");
> +     fputc ('\n', stdout);
>      }
>  
>    return DWARF_CB_OK;
> diff --git a/tests/funcretval.c b/tests/funcretval.c
> index 41198ab7..8e609898 100644
> --- a/tests/funcretval.c
> +++ b/tests/funcretval.c
> @@ -76,16 +76,16 @@ handle_function (Dwarf_Die *funcdie, void *arg)
>        attr = dwarf_attr_integrate (funcdie, DW_AT_type, &attr_mem);
>        if (dwarf_formref_die (attr, typedie) != NULL
>         && dwarf_tag (typedie) == DW_TAG_unspecified_type)
> -     puts ("returns unspecified type");
> +     fputs ("returns unspecified type\n", stdout);
>        else
> -     puts ("returns no value");
> +     fputs ("returns no value\n", stdout);
>      }
>    else
>      {
>        printf ("return value location:");
>        for (int i = 0; i < nlocops; ++i)
>       printf (" {%#x, %#" PRIx64 "}", locops[i].atom, locops[i].number);
> -      puts ("");
> +      fputc ('\n', stdout);
>      }
>  
>    return 0;
> diff --git a/tests/funcscopes.c b/tests/funcscopes.c
> index 689d376a..dd5eedb3 100644
> --- a/tests/funcscopes.c
> +++ b/tests/funcscopes.c
> @@ -158,7 +158,7 @@ handle_function (Dwarf_Die *funcdie, void *arg)
>             if (highpc != lowpc)
>               paddr (" .. ", highpc - 1, hiline == loline ? NULL : hiline);
>           }
> -       puts ("");
> +       fputc ('\n', stdout);
>  
>         print_vars (indent + INDENT, die);
>       }
> diff --git a/tests/get-aranges.c b/tests/get-aranges.c
> index 7f85cdad..b8e9bdde 100644
> --- a/tests/get-aranges.c
> +++ b/tests/get-aranges.c
> @@ -71,7 +71,7 @@ main (int argc, char *argv[])
>  
>                 if (dwarf_getarangeinfo (found, NULL, NULL, &cu_offset) != 0)
>                   {
> -                   puts ("failed to get CU die offset");
> +                   fputs ("failed to get CU die offset\n", stdout);
>                     result = 1;
>                   }
>                 else
> @@ -82,7 +82,7 @@ main (int argc, char *argv[])
>                     if (dwarf_offdie (dbg, cu_offset, &cu_die) == NULL
>                         || (cuname = dwarf_diename (&cu_die)) == NULL)
>                       {
> -                       puts ("failed to get CU die");
> +                       fputs ("failed to get CU die\n", stdout);
>                         result = 1;
>                       }
>                     else
> @@ -125,7 +125,7 @@ main (int argc, char *argv[])
>                 if (dwarf_offdie (dbg, cu_offset, &cu_die) == NULL
>                     || (cuname = dwarf_diename (&cu_die)) == NULL)
>                   {
> -                   puts ("failed to get CU die");
> +                   fputs ("failed to get CU die\n", stdout);
>                     result = 1;
>                   }
>                 else
> diff --git a/tests/get-files-define-file.c b/tests/get-files-define-file.c
> index 583f9852..367af52c 100644
> --- a/tests/get-files-define-file.c
> +++ b/tests/get-files-define-file.c
> @@ -31,7 +31,7 @@ print_dirs_and_files (Dwarf_Files *files, const char *const 
> *dirs,
>                     size_t nfiles, size_t ndirs)
>  {
>    if (dirs[0] == NULL)
> -    puts (" dirs[0] = (null)");
> +    fputs (" dirs[0] = (null)\n", stdout);
>    else
>      printf (" dirs[0] = \"%s\"\n", dirs[0]);
>    for (size_t i = 1; i < ndirs; ++i)
> diff --git a/tests/get-files.c b/tests/get-files.c
> index fa65aa93..80fa4b6f 100644
> --- a/tests/get-files.c
> +++ b/tests/get-files.c
> @@ -94,7 +94,7 @@ main (int argc, char *argv[])
>           }
>  
>         if (dirs[0] == NULL)
> -         puts (" dirs[0] = (null)");
> +         fputs (" dirs[0] = (null)\n", stdout);
>         else
>           printf (" dirs[0] = \"%s\"\n", dirs[0]);
>         for (size_t i = 1; i < ndirs; ++i)
> diff --git a/tests/get-pubnames.c b/tests/get-pubnames.c
> index 4777f49d..cc5433e4 100644
> --- a/tests/get-pubnames.c
> +++ b/tests/get-pubnames.c
> @@ -42,7 +42,7 @@ callback (Dwarf *dbg, Dwarf_Global *gl, void *arg 
> __attribute__ ((unused)))
>    if (dwarf_offdie (dbg, gl->cu_offset, &cu_die) == NULL
>        || (cuname = dwarf_diename (&cu_die)) == NULL)
>      {
> -      puts ("failed to get CU die");
> +      fputs ("failed to get CU die\n", stdout);
>        result = DWARF_CB_ABORT;
>      }
>    else
> @@ -53,7 +53,7 @@ callback (Dwarf *dbg, Dwarf_Global *gl, void *arg 
> __attribute__ ((unused)))
>    if (dwarf_offdie (dbg, gl->die_offset, &die) == NULL
>        || (diename = dwarf_diename (&die)) == NULL)
>      {
> -      puts ("failed to get object die");
> +      fputs ("failed to get object die\n", stdout);
>        result = DWARF_CB_ABORT;
>      }
>    else
> diff --git a/tests/line2addr.c b/tests/line2addr.c
> index 663746fd..c7a11759 100644
> --- a/tests/line2addr.c
> +++ b/tests/line2addr.c
> @@ -97,9 +97,9 @@ handle_module (Dwfl_Module *mod __attribute__ ((unused)),
>               printf (":%d", col);
>             if (modname[0] != '\0'
>                 || strcmp (file, a->file) || line != a->line || col != 0)
> -             puts (")");
> +             fputs (")\n", stdout);
>             else
> -             puts ("");
> +             fputc ('\n', stdout);
>           }
>       }
>        free (lines);
> diff --git a/tests/next-files.c b/tests/next-files.c
> index 9de5c8b0..490d100a 100644
> --- a/tests/next-files.c
> +++ b/tests/next-files.c
> @@ -68,7 +68,7 @@ main (int argc, char *argv[])
>           }
>  
>         if (dirs[0] == NULL)
> -         puts (" dirs[0] = (null)");
> +         fputs (" dirs[0] = (null)\n", stdout);
>         else
>           printf (" dirs[0] = \"%s\"\n", dirs[0]);
>         for (size_t i = 1; i < ndirs; ++i)
> diff --git a/tests/saridx.c b/tests/saridx.c
> index e7f0c566..dc28e3ec 100644
> --- a/tests/saridx.c
> +++ b/tests/saridx.c
> @@ -116,7 +116,7 @@ main (int argc, char *argv[])
>    /* Set the ELF version we are using here.  */
>    if (elf_version (EV_CURRENT) == EV_NONE)
>      {
> -      puts ("ELF library too old");
> +      fputs ("ELF library too old\n", stdout);
>        exit (1);
>      }
>  
> diff --git a/tests/scnnames.c b/tests/scnnames.c
> index 7f268258..ee34b786 100644
> --- a/tests/scnnames.c
> +++ b/tests/scnnames.c
> @@ -35,7 +35,7 @@ main (int argc, char *argv[])
>  
>    if (argc < 2)
>      {
> -      puts ("missing parameter");
> +      fputs ("missing parameter\n", stdout);
>        exit (1);
>      }
>  
> diff --git a/tests/sectiondump.c b/tests/sectiondump.c
> index 661e6440..d89aadc6 100644
> --- a/tests/sectiondump.c
> +++ b/tests/sectiondump.c
> @@ -130,7 +130,7 @@ handle_section (Elf *elf, Elf_Scn *scn)
>      }
>  
>    /* Separate form the next section.  */
> -  puts ("");
> +  fputc ('\n', stdout);
>  
>    /* All done correctly.  */
>    return 0;
> @@ -154,7 +154,7 @@ print_bytes (Elf_Data *data)
>        for (inner = 0; inner < 16 && cnt + inner < size; ++inner)
>       printf (" %02hhx", buf[cnt + inner]);
>  
> -      puts ("");
> +      fputc ('\n', stdout);
>      }
>  }
>  
> diff --git a/tests/show-die-info.c b/tests/show-die-info.c
> index bda459a5..7f8fa85e 100644
> --- a/tests/show-die-info.c
> +++ b/tests/show-die-info.c
> @@ -99,7 +99,7 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>    for (cnt = 0; cnt < 0xffff; ++cnt)
>      if (dwarf_hasattr (die, cnt))
>        printf (" %s", dwarf_attr_string (cnt) ?: "<unknown>");
> -  puts ("");
> +  fputc ('\n', stdout);
>  
>    if (dwarf_hasattr (die, DW_AT_low_pc) && dwarf_lowpc (die, &addr) == 0)
>      {
> @@ -111,13 +111,13 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>        if (dwarf_attr (die, DW_AT_low_pc, &attr) == NULL
>         || dwarf_formaddr (&attr, &addr2) != 0
>         || addr != addr2)
> -     puts ("************* DW_AT_low_pc verify failed ************");
> +     fputs ("************* DW_AT_low_pc verify failed ************\n", 
> stdout);
>        else if (! dwarf_hasform (&attr, DW_FORM_addr))
> -     puts ("************* DW_AT_low_pc form failed ************");
> +     fputs ("************* DW_AT_low_pc form failed ************\n", stdout);
>        else if (dwarf_whatform (&attr) != DW_FORM_addr)
> -     puts ("************* DW_AT_low_pc form (2) failed ************");
> +     fputs ("************* DW_AT_low_pc form (2) failed ************\n", 
> stdout);
>        else if (dwarf_whatattr (&attr) != DW_AT_low_pc)
> -     puts ("************* DW_AT_low_pc attr failed ************");
> +     fputs ("************* DW_AT_low_pc attr failed ************\n", stdout);
>      }
>    if (dwarf_hasattr (die, DW_AT_high_pc) && dwarf_highpc (die, &addr) == 0)
>      {
> @@ -128,13 +128,13 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>        if (dwarf_attr (die, DW_AT_high_pc, &attr) == NULL
>         || dwarf_formaddr (&attr, &addr2) != 0
>         || addr != addr2)
> -     puts ("************* DW_AT_high_pc verify failed ************");
> +     fputs ("************* DW_AT_high_pc verify failed ************\n", 
> stdout);
>        else if (! dwarf_hasform (&attr, DW_FORM_addr))
> -     puts ("************* DW_AT_high_pc form failed ************");
> +     fputs ("************* DW_AT_high_pc form failed ************\n", 
> stdout);
>        else if (dwarf_whatform (&attr) != DW_FORM_addr)
> -     puts ("************* DW_AT_high_pc form (2) failed ************");
> +     fputs ("************* DW_AT_high_pc form (2) failed ************\n", 
> stdout);
>        else if (dwarf_whatattr (&attr) != DW_AT_high_pc)
> -     puts ("************* DW_AT_high_pc attr failed ************");
> +     fputs ("************* DW_AT_high_pc attr failed ************\n", 
> stdout);
>      }
>  
>    if (dwarf_hasattr (die, DW_AT_byte_size) && (i = dwarf_bytesize (die)) != 
> -1)
> @@ -146,14 +146,14 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>        if (dwarf_attr (die, DW_AT_byte_size, &attr) == NULL
>         || dwarf_formudata (&attr, &u2) != 0
>         || i != (int) u2)
> -     puts ("************* DW_AT_byte_size verify failed ************");
> +     fputs ("************* DW_AT_byte_size verify failed ************\n", 
> stdout);
>        else if (! dwarf_hasform (&attr, DW_FORM_data1)
>              && ! dwarf_hasform (&attr, DW_FORM_data2)
>              && ! dwarf_hasform (&attr, DW_FORM_data4)
>              && ! dwarf_hasform (&attr, DW_FORM_data8)
>              && ! dwarf_hasform (&attr, DW_FORM_sdata)
>              && ! dwarf_hasform (&attr, DW_FORM_udata))
> -     puts ("************* DW_AT_byte_size form failed ************");
> +     fputs ("************* DW_AT_byte_size form failed ************\n", 
> stdout);
>        else if ((u = dwarf_whatform (&attr)) == 0
>              || (u != DW_FORM_data1
>                  && u != DW_FORM_data2
> @@ -161,9 +161,9 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>                  && u != DW_FORM_data8
>                  && u != DW_FORM_sdata
>                  && u != DW_FORM_udata))
> -     puts ("************* DW_AT_byte_size form (2) failed ************");
> +     fputs ("************* DW_AT_byte_size form (2) failed ************\n", 
> stdout);
>        else if (dwarf_whatattr (&attr) != DW_AT_byte_size)
> -     puts ("************* DW_AT_byte_size attr failed ************");
> +     fputs ("************* DW_AT_byte_size attr failed ************\n", 
> stdout);
>      }
>    if (dwarf_hasattr (die, DW_AT_bit_size) && (i = dwarf_bitsize (die)) != -1)
>      {
> @@ -174,14 +174,14 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>        if (dwarf_attr (die, DW_AT_bit_size, &attr) == NULL
>         || dwarf_formudata (&attr, &u2) != 0
>         || i != (int) u2)
> -     puts ("************* DW_AT_bit_size test failed ************");
> +     fputs ("************* DW_AT_bit_size test failed ************\n", 
> stdout);
>        else if (! dwarf_hasform (&attr, DW_FORM_data1)
>              && ! dwarf_hasform (&attr, DW_FORM_data2)
>              && ! dwarf_hasform (&attr, DW_FORM_data4)
>              && ! dwarf_hasform (&attr, DW_FORM_data8)
>              && ! dwarf_hasform (&attr, DW_FORM_sdata)
>              && ! dwarf_hasform (&attr, DW_FORM_udata))
> -     puts ("************* DW_AT_bit_size form failed ************");
> +     fputs ("************* DW_AT_bit_size form failed ************\n", 
> stdout);
>        else if ((u = dwarf_whatform (&attr)) == 0
>              || (u != DW_FORM_data1
>                  && u != DW_FORM_data2
> @@ -189,9 +189,9 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>                  && u != DW_FORM_data8
>                  && u != DW_FORM_sdata
>                  && u != DW_FORM_udata))
> -     puts ("************* DW_AT_bit_size form (2) failed ************");
> +     fputs ("************* DW_AT_bit_size form (2) failed ************\n", 
> stdout);
>        else if (dwarf_whatattr (&attr) != DW_AT_bit_size)
> -     puts ("************* DW_AT_bit_size attr failed ************");
> +     fputs ("************* DW_AT_bit_size attr failed ************\n", 
> stdout);
>      }
>    if (dwarf_hasattr (die, DW_AT_bit_offset)
>        && (i = dwarf_bitoffset (die)) != -1)
> @@ -203,14 +203,14 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>        if (dwarf_attr (die, DW_AT_bit_offset, &attr) == NULL
>         || dwarf_formudata (&attr, &u2) != 0
>         || i != (int) u2)
> -     puts ("************* DW_AT_bit_offset test failed ************");
> +     fputs ("************* DW_AT_bit_offset test failed ************\n", 
> stdout);
>        else if (! dwarf_hasform (&attr, DW_FORM_data1)
>              && ! dwarf_hasform (&attr, DW_FORM_data2)
>              && ! dwarf_hasform (&attr, DW_FORM_data4)
>              && ! dwarf_hasform (&attr, DW_FORM_data8)
>              && ! dwarf_hasform (&attr, DW_FORM_sdata)
>              && ! dwarf_hasform (&attr, DW_FORM_udata))
> -     puts ("************* DW_AT_bit_offset form failed ************");
> +     fputs ("************* DW_AT_bit_offset form failed ************\n", 
> stdout);
>        else if ((u = dwarf_whatform (&attr)) == 0
>              || (u != DW_FORM_data1
>                  && u != DW_FORM_data2
> @@ -218,9 +218,9 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>                  && u != DW_FORM_data8
>                  && u != DW_FORM_sdata
>                  && u != DW_FORM_udata))
> -     puts ("************* DW_AT_bit_offset form (2) failed ************");
> +     fputs ("************* DW_AT_bit_offset form (2) failed ************\n", 
> stdout);
>        else if (dwarf_whatattr (&attr) != DW_AT_bit_offset)
> -     puts ("************* DW_AT_bit_offset attr failed ************");
> +     fputs ("************* DW_AT_bit_offset attr failed ************\n", 
> stdout);
>      }
>  
>    if (dwarf_hasattr (die, DW_AT_language) && (i = dwarf_srclang (die)) != -1)
> @@ -232,14 +232,14 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>        if (dwarf_attr (die, DW_AT_language, &attr) == NULL
>         || dwarf_formudata (&attr, &u2) != 0
>         || i != (int) u2)
> -     puts ("************* DW_AT_language test failed ************");
> +     fputs ("************* DW_AT_language test failed ************\n", 
> stdout);
>        else if (! dwarf_hasform (&attr, DW_FORM_data1)
>              && ! dwarf_hasform (&attr, DW_FORM_data2)
>              && ! dwarf_hasform (&attr, DW_FORM_data4)
>              && ! dwarf_hasform (&attr, DW_FORM_data8)
>              && ! dwarf_hasform (&attr, DW_FORM_sdata)
>              && ! dwarf_hasform (&attr, DW_FORM_udata))
> -     puts ("************* DW_AT_language form failed ************");
> +     fputs ("************* DW_AT_language form failed ************\n", 
> stdout);
>        else if ((u = dwarf_whatform (&attr)) == 0
>              || (u != DW_FORM_data1
>                  && u != DW_FORM_data2
> @@ -247,9 +247,9 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>                  && u != DW_FORM_data8
>                  && u != DW_FORM_sdata
>                  && u != DW_FORM_udata))
> -     puts ("************* DW_AT_language form (2) failed ************");
> +     fputs ("************* DW_AT_language form (2) failed ************\n", 
> stdout);
>        else if (dwarf_whatattr (&attr) != DW_AT_language)
> -     puts ("************* DW_AT_language attr failed ************");
> +     fputs ("************* DW_AT_language attr failed ************\n", 
> stdout);
>      }
>  
>    if (dwarf_hasattr (die, DW_AT_ordering)
> @@ -262,14 +262,14 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>        if (dwarf_attr (die, DW_AT_ordering, &attr) == NULL
>         || dwarf_formudata (&attr, &u2) != 0
>         || i != (int) u2)
> -     puts ("************* DW_AT_ordering test failed ************");
> +     fputs ("************* DW_AT_ordering test failed ************\n", 
> stdout);
>        else if (! dwarf_hasform (&attr, DW_FORM_data1)
>              && ! dwarf_hasform (&attr, DW_FORM_data2)
>              && ! dwarf_hasform (&attr, DW_FORM_data4)
>              && ! dwarf_hasform (&attr, DW_FORM_data8)
>              && ! dwarf_hasform (&attr, DW_FORM_sdata)
>              && ! dwarf_hasform (&attr, DW_FORM_udata))
> -     puts ("************* DW_AT_ordering failed ************");
> +     fputs ("************* DW_AT_ordering failed ************\n", stdout);
>        else if ((u = dwarf_whatform (&attr)) == 0
>              || (u != DW_FORM_data1
>                  && u != DW_FORM_data2
> @@ -277,9 +277,9 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>                  && u != DW_FORM_data8
>                  && u != DW_FORM_sdata
>                  && u != DW_FORM_udata))
> -     puts ("************* DW_AT_ordering form (2) failed ************");
> +     fputs ("************* DW_AT_ordering form (2) failed ************\n", 
> stdout);
>        else if (dwarf_whatattr (&attr) != DW_AT_ordering)
> -     puts ("************* DW_AT_ordering attr failed ************");
> +     fputs ("************* DW_AT_ordering attr failed ************\n", 
> stdout);
>      }
>  
>    if (dwarf_hasattr (die, DW_AT_comp_dir))
> @@ -287,7 +287,7 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>        Dwarf_Attribute attr;
>        if (dwarf_attr (die, DW_AT_comp_dir, &attr) == NULL
>         || (name = dwarf_formstring (&attr)) == NULL)
> -     puts ("************* DW_AT_comp_dir attr failed ************");
> +     fputs ("************* DW_AT_comp_dir attr failed ************\n", 
> stdout);
>        else
>       printf ("%*s directory : %s\n", n * 5, "", name);
>      }
> @@ -297,7 +297,7 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>        Dwarf_Attribute attr;
>        if (dwarf_attr (die, DW_AT_producer, &attr) == NULL
>         || (name = dwarf_formstring (&attr)) == NULL)
> -     puts ("************* DW_AT_comp_dir attr failed ************");
> +     fputs ("************* DW_AT_comp_dir attr failed ************\n", 
> stdout);
>        else
>       printf ("%*s producer  : %s\n", n * 5, "", name);
>      }
> diff --git a/tests/showptable.c b/tests/showptable.c
> index 3d0552fe..83208041 100644
> --- a/tests/showptable.c
> +++ b/tests/showptable.c
> @@ -34,7 +34,7 @@ main (int argc, char *argv[])
>  
>    if (argc < 2)
>      {
> -      puts ("missing parameter");
> +      fputs ("missing parameter\n", stdout);
>        exit (1);
>      }
>  
> diff --git a/tests/test-nlist.c b/tests/test-nlist.c
> index 679c911b..8cb65791 100644
> --- a/tests/test-nlist.c
> +++ b/tests/test-nlist.c
> @@ -49,7 +49,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
>    if (nlist (".libs/test-nlist", nl) != 0
>        && nlist ("./test-nlist", nl) != 0)
>      {
> -      puts ("nlist failed");
> +      fputs ("nlist failed\n", stdout);
>        exit (1);
>      }
>  
> -- 
> 2.30.2
> 
> 

Reply via email to