From 49d6c7427686db790dcf2c47b8ce6043be672e63 Mon Sep 17 00:00:00 2001 From: Wim Lavrijsen Date: Wed, 1 Nov 2023 09:32:55 -0700 Subject: [PATCH] fix gcc12 warnings (from upstream) --- cling/src/build/rmkdepend/include.c | 28 +++++++----------------- cling/src/core/cont/inc/TList.h | 12 ++++++---- cling/src/core/cont/inc/TMap.h | 12 ++++++---- cling/src/core/cont/inc/TObjArray.h | 12 ++++++---- cling/src/core/cont/inc/TOrdCollection.h | 12 ++++++---- cling/src/core/unix/src/TUnixSystem.cxx | 20 +++++++---------- 6 files changed, 48 insertions(+), 48 deletions(-) diff --git a/cling/src/build/rmkdepend/include.c b/cling/src/build/rmkdepend/include.c index 95c5c746..bab47ac7 100644 --- a/cling/src/build/rmkdepend/include.c +++ b/cling/src/build/rmkdepend/include.c @@ -40,28 +40,21 @@ extern char *notdotdot[ ]; extern boolean show_where_not; extern boolean warn_multiple; - -boolean -isdot(p) -register char *p; +boolean isdot(register char *p) { if (p && *p++ == '.' && *p++ == '\0') return(TRUE); return(FALSE); } -boolean -isdotdot(p) -register char *p; +boolean isdotdot(register char *p) { if (p && *p++ == '.' && *p++ == '.' && *p++ == '\0') return(TRUE); return(FALSE); } -boolean -issymbolic(dir, component) -register char *dir, *component; +boolean issymbolic(register char *dir, register char *component) { #ifdef S_IFLNK struct stat st; @@ -89,9 +82,7 @@ register char *dir, *component; * Any of the 'x/..' sequences within the name can be eliminated. * (but only if 'x' is not a symbolic link!!) */ -void -remove_dotdot(path) -char *path; +void remove_dotdot(char *path) { register char *end, *from, *to, **cp; char *components[ MAXFILES ], @@ -161,8 +152,7 @@ char *path; /* * Add an include file to the list of those included by 'file'. */ -struct inclist *newinclude(newfile, incstring) - register char *newfile, *incstring; +struct inclist *newinclude(register char *newfile, register char *incstring) { register struct inclist *ip; @@ -182,9 +172,7 @@ struct inclist *newinclude(newfile, incstring) return(ip); } -void -included_by(ip, newfile) -register struct inclist *ip, *newfile; +void included_by(register struct inclist *ip, register struct inclist *newfile) { register int i; @@ -311,11 +299,11 @@ struct inclist *inc_path(char *file, char *include, boolean dot) { */ if (!found) for (pp = includedirs; *pp; pp++) { - if (strlen(*pp) + strlen(include) + 2 > sizeof(path)) { + int retlen = snprintf(path, BUFSIZ, "%s/%s", *pp, include); + if (retlen <= 0 || BUFSIZ < retlen) { warning1("\t%s/%s too long\n", *pp, include); continue; } - sprintf(path, "%s/%s", *pp, include); remove_dotdot(path); #ifdef _WIN32 if (stat(path, &st) == 0 && (st.st_mode & S_IFREG)) { diff --git a/cling/src/core/cont/inc/TList.h b/cling/src/core/cont/inc/TList.h index bb4b735d..58d02980 100644 --- a/cling/src/core/cont/inc/TList.h +++ b/cling/src/core/cont/inc/TList.h @@ -196,10 +196,14 @@ class TObjOptLink : public TObjLink { // Iterator of linked list. // // // ////////////////////////////////////////////////////////////////////////// -class TListIter : public TIterator, - public std::iterator { +class TListIter : public TIterator { +public: + using iterator_category = std::bidirectional_iterator_tag; + using value_type = TObject *; + using difference_type = std::ptrdiff_t; + using pointer = TObject **; + using const_pointer = const TObject **; + using reference = const TObject *&; protected: using TObjLinkPtr_t = std::shared_ptr; diff --git a/cling/src/core/cont/inc/TMap.h b/cling/src/core/cont/inc/TMap.h index 93f4eba1..a97b88a2 100644 --- a/cling/src/core/cont/inc/TMap.h +++ b/cling/src/core/cont/inc/TMap.h @@ -137,10 +137,14 @@ typedef TPair TAssoc; // for backward compatibility // // ////////////////////////////////////////////////////////////////////////// -class TMapIter : public TIterator, - public std::iterator { +class TMapIter : public TIterator { +public: + using iterator_category = std::bidirectional_iterator_tag; + using value_type = TObject *; + using difference_type = std::ptrdiff_t; + using pointer = TObject **; + using const_pointer = const TObject **; + using reference = const TObject *&; private: const TMap *fMap; //map being iterated diff --git a/cling/src/core/cont/inc/TObjArray.h b/cling/src/core/cont/inc/TObjArray.h index e638c930..a9dbe961 100644 --- a/cling/src/core/cont/inc/TObjArray.h +++ b/cling/src/core/cont/inc/TObjArray.h @@ -120,10 +120,14 @@ friend class TObjArrayIter; // // ////////////////////////////////////////////////////////////////////////// -class TObjArrayIter : public TIterator, - public std::iterator { +class TObjArrayIter : public TIterator { +public: + using iterator_category = std::bidirectional_iterator_tag; + using value_type = TObject *; + using difference_type = std::ptrdiff_t; + using pointer = TObject **; + using const_pointer = const TObject **; + using reference = const TObject *&; private: const TObjArray *fArray; //array being iterated diff --git a/cling/src/core/cont/inc/TOrdCollection.h b/cling/src/core/cont/inc/TOrdCollection.h index 6821a0ea..4a1e10fe 100644 --- a/cling/src/core/cont/inc/TOrdCollection.h +++ b/cling/src/core/cont/inc/TOrdCollection.h @@ -91,10 +91,14 @@ friend class TOrdCollectionIter; // // ////////////////////////////////////////////////////////////////////////// -class TOrdCollectionIter : public TIterator, - public std::iterator { +class TOrdCollectionIter : public TIterator { +public: + using iterator_category = std::bidirectional_iterator_tag; + using value_type = TObject *; + using difference_type = std::ptrdiff_t; + using pointer = TObject **; + using const_pointer = const TObject **; + using reference = const TObject *&; private: const TOrdCollection *fCol; //collection being iterated diff --git a/cling/src/core/unix/src/TUnixSystem.cxx b/cling/src/core/unix/src/TUnixSystem.cxx index af75ab51..33b35819 100644 --- a/cling/src/core/unix/src/TUnixSystem.cxx +++ b/cling/src/core/unix/src/TUnixSystem.cxx @@ -656,17 +656,13 @@ void TUnixSystem::SetDisplay() STRUCT_UTMP *utmp_entry = utmp.SearchUtmpEntry(tty); if (utmp_entry) { if (utmp_entry->ut_host[0]) { - if (strchr(utmp_entry->ut_host, ':')) { - Setenv("DISPLAY", utmp_entry->ut_host); - Warning("SetDisplay", "DISPLAY not set, setting it to %s", - utmp_entry->ut_host); - } else { - char disp[260]; - snprintf(disp, sizeof(disp), "%s:0.0", utmp_entry->ut_host); - Setenv("DISPLAY", disp); - Warning("SetDisplay", "DISPLAY not set, setting it to %s", - disp); - } + TString disp; + for (unsigned n = 0; (n < sizeof(utmp_entry->ut_host)) && utmp_entry->ut_host[n]; n++) + disp.Append(utmp_entry->ut_host[n]); + if (disp.First(':') == kNPOS) + disp.Append(":0.0"); + Setenv("DISPLAY", disp.Data()); + Warning("SetDisplay", "DISPLAY not set, setting it to %s", disp.Data()); } #ifndef UTMP_NO_ADDR else if (utmp_entry->ut_addr) { @@ -681,7 +677,7 @@ void TUnixSystem::SetDisplay() char hbuf[NI_MAXHOST + 4]; if (getnameinfo(sa, sizeof(struct sockaddr), hbuf, sizeof(hbuf), nullptr, 0, NI_NAMEREQD) == 0) { assert( strlen(hbuf) < NI_MAXHOST ); - strcat(hbuf, ":0.0"); + strlcat(hbuf, ":0.0", sizeof(hbuf)); Setenv("DISPLAY", hbuf); Warning("SetDisplay", "DISPLAY not set, setting it to %s", hbuf);