From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 6C0FD38654A2 for ; Thu, 20 Oct 2022 18:26:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C0FD38654A2 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-x629.google.com with SMTP id c24so110201plo.3 for ; Thu, 20 Oct 2022 11:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fofAaqthGNsW41BUX2rBUBspzBBZjA/gmwSYjl4/fjY=; b=oxTgRcmsCDCAIqdhbmxIJQSModewpry6nY6ZuPJhiF6UqlOuJFqk19p6oSSxiRNPxd mQpLkFpEDY8lGD2Wgl3SbACJdGEwNx/T4MdXebjr9PJHe3sULLZxqWkHGjJf+D2uKOs4 aojTTyV0txFSF3hpv3bRZMNqlk379EA+2F2sc9ADbPzUZYg6b9TVPAbEtVpX3akX4MZi Xo4IikvvuUdEqqm8op0/2aeNSQNAo8UepnQrYCVnAbASygHKe7ghB59uxtUbfsRobC6z 3YLYmxy742TmqJZ/gdtyEkJrLGRCLmFFvN5i5Y4ioeJg/iI36c3J+oBDna0GHB1U27v7 IkrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fofAaqthGNsW41BUX2rBUBspzBBZjA/gmwSYjl4/fjY=; b=OgvosIJeQidYnwQ8oUNYPZx/0D65nKV43Hq9ZSLm0shIjaCEGpAsy30473kfM+hPEQ 224QjNe1+kscuI6DXjQISSz+d3dukFiclk0EyqePZTTtC6kT2UB3phGw9vmNRnIIjRAI hR21RM+B3FuFG/LVe8MkmkTsDabju+y4O43nNLWB3j0rV5luctMQDRaQD6vULIpHlAoH CJoDxADESDdqGkEaa0sC5BcsNQQKZNSemmwujN+6Dnd1M1BovftcbT2UtpQz0nULj0xF +j81c71Rg7og7tXGH1zRnd0UHGzBVONU2ZJKOyIvzoNyH3AImMrK6q+mTwAGvbbfAv6e KC8w== X-Gm-Message-State: ACrzQf2PYgws4QtogoAZ7iRhlAWmMvVmcNvM+nybkcL/Vs40lFh7EH2J luZIYKEgxKHKDjndJKjTdpigYm3WgGLVaA== X-Google-Smtp-Source: AMsMyM4B8yPDEqaXoHptpngmCQjT+JtPJlMdHeMUXbwoqT1KuJAT14LN6o86CWuAtLa9bh8sCHVVfQ== X-Received: by 2002:a17:903:3249:b0:181:150c:fcc7 with SMTP id ji9-20020a170903324900b00181150cfcc7mr15710180plb.119.1666290399800; Thu, 20 Oct 2022 11:26:39 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id w15-20020a17090a460f00b00202fbd9c21dsm115067pjg.48.2022.10.20.11.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 11:26:39 -0700 (PDT) From: Yonggang Luo To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH 09/25] include libgen.h in system.h Date: Fri, 21 Oct 2022 02:25:48 +0800 Message-Id: <20221020182603.815-10-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221020182603.815-1-luoyonggang@gmail.com> References: <20221020182603.815-1-luoyonggang@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: basename function are accessed multiple place, but used without include libgen.h Signed-off-by: Yonggang Luo --- lib/system.h | 1 + libdw/dwarf_getsrc_file.c | 2 +- libdwfl/dwfl_module_getsrc_file.c | 2 +- libdwfl/dwfl_segment_report_module.c | 2 +- libdwfl/find-debuginfo.c | 6 +++--- libdwfl/link_map.c | 2 +- src/addr2line.c | 4 ++-- src/nm.c | 4 ++-- src/stack.c | 2 +- src/strip.c | 2 +- 10 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/system.h b/lib/system.h index 561d3e03..7132cd6d 100644 --- a/lib/system.h +++ b/lib/system.h @@ -42,6 +42,7 @@ /* System dependend headers */ #include #include +#include #if HAVE_DECL_MMAP #include #endif diff --git a/libdw/dwarf_getsrc_file.c b/libdw/dwarf_getsrc_file.c index 5289c7da..884fea32 100644 --- a/libdw/dwarf_getsrc_file.c +++ b/libdw/dwarf_getsrc_file.c @@ -98,7 +98,7 @@ dwarf_getsrc_file (Dwarf *dbg, const char *fname, int lineno, int column, /* Match the name with the name the user provided. */ const char *fname2 = line->files->info[lastfile].name; if (is_basename) - lastmatch = strcmp (basename (fname2), fname) == 0; + lastmatch = strcmp (basename ((char *)fname2), fname) == 0; else lastmatch = strcmp (fname2, fname) == 0; } diff --git a/libdwfl/dwfl_module_getsrc_file.c b/libdwfl/dwfl_module_getsrc_file.c index cea2ba41..6daf29d6 100644 --- a/libdwfl/dwfl_module_getsrc_file.c +++ b/libdwfl/dwfl_module_getsrc_file.c @@ -103,7 +103,7 @@ dwfl_module_getsrc_file (Dwfl_Module *mod, { /* Match the name with the name the user provided. */ lastfile = file; - lastmatch = !strcmp (is_basename ? basename (file) : file, + lastmatch = !strcmp (is_basename ? basename ((char *)file) : file, fname); } } diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 287fc002..aa228254 100644 --- a/libdwfl/dwfl_segment_report_module.c +++ b/libdwfl/dwfl_segment_report_module.c @@ -736,7 +736,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, bias += fixup; if (module->name[0] != '\0') { - name = basename (module->name); + name = basename ((char *)module->name); name_is_final = true; } break; diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c index 7f7ab632..a9b7be3d 100644 --- a/libdwfl/find-debuginfo.c +++ b/libdwfl/find-debuginfo.c @@ -164,7 +164,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, { bool cancheck = debuglink_crc != (GElf_Word) 0; - const char *file_basename = file_name == NULL ? NULL : basename (file_name); + const char *file_basename = file_name == NULL ? NULL : basename ((char *)file_name); char *localname = NULL; /* We invent a debuglink .debug name if NULL, but then want to try the @@ -278,7 +278,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, else { subdir = NULL; - file = basename (debuglink_file); + file = basename ((char *)debuglink_file); } try_file_basename = debuglink_null; break; @@ -306,7 +306,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, if (mod->dw != NULL && (p[0] == '\0' || p[0] == '/')) { fd = try_open (&main_stat, dir, ".dwz", - basename (file), &fname); + basename ((char *)file), &fname); if (fd < 0) { if (errno != ENOENT && errno != ENOTDIR) diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index 7ec7eca1..403d4ee5 100644 --- a/libdwfl/link_map.c +++ b/libdwfl/link_map.c @@ -469,7 +469,7 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata, if (r_debug_info_module == NULL) { // XXX hook for sysroot - mod = __libdwfl_report_elf (dwfl, basename (name), + mod = __libdwfl_report_elf (dwfl, basename ((char *)name), name, fd, elf, base, true, true); if (mod != NULL) diff --git a/src/addr2line.c b/src/addr2line.c index 7768b266..3abf1d7a 100644 --- a/src/addr2line.c +++ b/src/addr2line.c @@ -381,7 +381,7 @@ print_dwarf_function (Dwfl_Module *mod, Dwarf_Addr addr) if (file == NULL) file = "???"; else if (only_basenames) - file = basename (file); + file = basename ((char *)file); else if (use_comp_dir && file[0] != '/') { const char *const *dirs; @@ -564,7 +564,7 @@ print_src (const char *src, int lineno, int linecol, Dwarf_Die *cu) const char *comp_dir_sep = ""; if (only_basenames) - src = basename (src); + src = basename ((char *)src); else if (use_comp_dir && src[0] != '/') { Dwarf_Attribute attr; diff --git a/src/nm.c b/src/nm.c index b46c1fd7..717ec0f6 100644 --- a/src/nm.c +++ b/src/nm.c @@ -1417,7 +1417,7 @@ show_symbols (int fd, Ebl *ebl, GElf_Ehdr *ehdr, int lineno; (void) dwarf_lineno (line, &lineno); const char *file = dwarf_linesrc (line, NULL, NULL); - file = (file != NULL) ? basename (file) : "???"; + file = (file != NULL) ? basename ((char *)file) : "???"; int n; n = obstack_printf (&whereob, "%s:%d%c", file, lineno, '\0'); @@ -1448,7 +1448,7 @@ show_symbols (int fd, Ebl *ebl, GElf_Ehdr *ehdr, { /* We found the line. */ int n = obstack_printf (&whereob, "%s:%" PRIu64 "%c", - basename ((*found)->file), + basename ((char *)(*found)->file), (*found)->lineno, '\0'); sym_mem[nentries_used].where = obstack_finish (&whereob); diff --git a/src/stack.c b/src/stack.c index 534aa93c..82413772 100644 --- a/src/stack.c +++ b/src/stack.c @@ -152,7 +152,7 @@ module_callback (Dwfl_Module *mod, void **userdata __attribute__((unused)), int width = get_addr_width (mod); printf ("0x%0*" PRIx64 "-0x%0*" PRIx64 " %s\n", - width, start, width, end, basename (name)); + width, start, width, end, basename ((char *)name)); const unsigned char *id; GElf_Addr id_vaddr; diff --git a/src/strip.c b/src/strip.c index 2a2cc801..6ac987fd 100644 --- a/src/strip.c +++ b/src/strip.c @@ -1800,7 +1800,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, elf_errmsg (-1)); } - char *debug_basename = basename (debug_fname_embed ?: debug_fname); + char *debug_basename = basename ((char *)(debug_fname_embed ?: debug_fname)); off_t crc_offset = strlen (debug_basename) + 1; /* Align to 4 byte boundary */ crc_offset = ((crc_offset - 1) & ~3) + 4; -- 2.36.1.windows.1