From f6d7309c6778222a450dfdf1c7c26dde4ff91872 Mon Sep 17 00:00:00 2001 From: Alexey Sheplyakov Date: Thu, 11 May 2023 05:26:45 +0400 Subject: [PATCH] methods: avoid compilation error with GCC 13 http.cc:1014:18: error: ignoring return value of 'const _CharT* std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::c_str() const [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator]', declared with attribute 'nodiscard' [-Werror=unused-result] 1014 | FailFile.c_str(); // Make sure we dont do a malloc in the signal handler | ~~~~~~~~~~~~~~^~ In file included from /usr/include/c++/13/string:54, from ../include/apt-pkg/fileutl.h:23, from http.cc:29: /usr/include/c++/13/bits/basic_string.h:2594:7: note: declared here 2594 | c_str() const _GLIBCXX_NOEXCEPT | ^~~~~ cc1plus: all warnings being treated as errors make[1]: *** [Makefile:622: http.o] Error 1 Similarly in ftp.cc and rsh.cc --- methods/ftp.cc | 2 +- methods/http.cc | 2 +- methods/rsh.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/methods/ftp.cc b/methods/ftp.cc index d2508cd..dd1f854 100644 --- a/methods/ftp.cc +++ b/methods/ftp.cc @@ -1048,7 +1048,7 @@ bool FtpMethod::Fetch(FetchItem *Itm) URIStart(Res); FailFile = Itm->DestFile; - FailFile.c_str(); // Make sure we dont do a malloc in the signal handler + (void)FailFile.c_str(); // Make sure we dont do a malloc in the signal handler FailFd = Fd.Fd(); bool Missing; diff --git a/methods/http.cc b/methods/http.cc index 32ab5a6..ea2be71 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -1011,7 +1011,7 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv) return 5; FailFile = Queue->DestFile; - FailFile.c_str(); // Make sure we dont do a malloc in the signal handler + (void)FailFile.c_str(); // Make sure we dont do a malloc in the signal handler FailFd = File->Fd(); FailTime = Srv->Date; diff --git a/methods/rsh.cc b/methods/rsh.cc index 685df42..de59ce2 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -475,7 +475,7 @@ bool RSHMethod::Fetch(FetchItem *Itm) URIStart(Res); FailFile = Itm->DestFile; - FailFile.c_str(); // Make sure we dont do a malloc in the signal handler + (void)FailFile.c_str(); // Make sure we dont do a malloc in the signal handler FailFd = Fd.Fd(); bool Missing; -- 2.33.7