From: <eri...@us...> - 2025-05-23 15:44:05
|
Revision: 12987 http://sourceforge.net/p/oorexx/code-0/12987 Author: erich_st Date: 2025-05-23 15:44:02 +0000 (Fri, 23 May 2025) Log Message: ----------- more fixes for gcc warnings Modified Paths: -------------- main/trunk/interpreter/classes/NumberStringClass.hpp main/trunk/interpreter/classes/StringClass.cpp main/trunk/interpreter/classes/StringClass.hpp main/trunk/interpreter/classes/StringClassBit.cpp main/trunk/interpreter/classes/StringClassConversion.cpp main/trunk/interpreter/classes/StringClassSub.cpp main/trunk/interpreter/runtime/MethodArguments.hpp main/trunk/interpreter/runtime/RexxUtilCommon.cpp Modified: main/trunk/interpreter/classes/NumberStringClass.hpp =================================================================== --- main/trunk/interpreter/classes/NumberStringClass.hpp 2025-05-21 08:49:55 UTC (rev 12986) +++ main/trunk/interpreter/classes/NumberStringClass.hpp 2025-05-23 15:44:02 UTC (rev 12987) @@ -132,7 +132,19 @@ current += len; } inline void append(const char *d, size_t l) { memcpy(current, d, l); current += l; } - inline void append(char c) { *current++ = c; } + inline void append(char c) + { +// avoid warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] +// (or similar) in gcc 12 and above, due to our RexxString char stringData[4] +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif + *current++ = c; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + } inline void addDigits(const char *d, wholenumber_t len) { for (wholenumber_t i = 0; i < len; i++) Modified: main/trunk/interpreter/classes/StringClass.cpp =================================================================== --- main/trunk/interpreter/classes/StringClass.cpp 2025-05-21 08:49:55 UTC (rev 12986) +++ main/trunk/interpreter/classes/StringClass.cpp 2025-05-23 15:44:02 UTC (rev 12987) @@ -1608,12 +1608,16 @@ // copy the data over, uppercasing as we go. while (data < endData) { -// avoid GCC warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] -// (or similar) in gcc 10 and above, due to our RexxString char stringData[4] +// avoid warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] +// (or similar) in gcc 12 and above, due to our RexxString char stringData[4] +#ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif *outdata++ = Utilities::toUpper(*data++); +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif } // we know this string does not contain lowercase characters newstring->setUpperOnly(); @@ -1695,12 +1699,16 @@ // copy the data over, lowercasing as we go. while (data < endData) { -// avoid GCC warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] -// (or similar) in gcc 10 and above, due to our RexxString char stringData[4] +// avoid warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] +// (or similar) in gcc 12 and above, due to our RexxString char stringData[4] +#ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif *outdata++ = Utilities::toLower(*data++); +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif } // we know this string does not contain uppercase characters newstring->setLowerOnly(); @@ -1799,12 +1807,16 @@ // now lowercase in place for (size_t i = 0; i < _length; i++) { -// avoid GCC warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] -// (or similar) in gcc 10 and above, due to our RexxString char stringData[4] +// avoid warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] +// (or similar) in gcc 12 and above, due to our RexxString char stringData[4] +#ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif *data = Utilities::toLower(*data); +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif data++; } return newstring; @@ -1834,12 +1846,16 @@ // now uppercase in place for (size_t i = 0; i < _length; i++) { -// avoid GCC warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] -// (or similar) in gcc 10 and above, due to our RexxString char stringData[4] +// avoid warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] +// (or similar) in gcc 12 and above, due to our RexxString char stringData[4] +#ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif *data = Utilities::toUpper(*data); +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif data++; } return newstring; @@ -2255,12 +2271,16 @@ while (indata < endData) { -// avoid GCC warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] -// (or similar) in gcc 10 and above, due to our RexxString char stringData[4] +// avoid warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] +// (or similar) in gcc 12 and above, due to our RexxString char stringData[4] +#ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif *outdata++ = Utilities::toUpper(*indata++); +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif } // flag as containing only uppercase characters newObj->setUpperOnly(); Modified: main/trunk/interpreter/classes/StringClass.hpp =================================================================== --- main/trunk/interpreter/classes/StringClass.hpp 2025-05-21 08:49:55 UTC (rev 12986) +++ main/trunk/interpreter/classes/StringClass.hpp 2025-05-23 15:44:02 UTC (rev 12987) @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------*/ /* */ /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ -/* Copyright (c) 2005-2019 Rexx Language Association. All rights reserved. */ +/* Copyright (c) 2005-2025 Rexx Language Association. All rights reserved. */ /* */ /* This program and the accompanying materials are made available under */ /* the terms of the Common Public License v1.0 which accompanies this */ @@ -92,7 +92,19 @@ inline void init(RexxString *s) { current = s->getWritableData(); } inline void append(const char *d, size_t l) { memcpy(current, d, l); current += l; } inline void append(const char *d) { size_t l = strlen(d); memcpy(current, d, l); current += l; } - inline void append(char c) { *current++ = c; } + inline void append(char c) + { +// avoid warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] +// (or similar) in gcc 12 and above, due to our RexxString char stringData[4] +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif + *current++ = c; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + } inline void append(RexxString *s) { append(s->getStringData(), s->getLength()); } inline void pad(char c, size_t l) { memset(current, c, l); current += l; } Modified: main/trunk/interpreter/classes/StringClassBit.cpp =================================================================== --- main/trunk/interpreter/classes/StringClassBit.cpp 2025-05-21 08:49:55 UTC (rev 12986) +++ main/trunk/interpreter/classes/StringClassBit.cpp 2025-05-23 15:44:02 UTC (rev 12987) @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------*/ /* */ /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ -/* Copyright (c) 2005-2014 Rexx Language Association. All rights reserved. */ +/* Copyright (c) 2005-2025 Rexx Language Association. All rights reserved. */ /* */ /* This program and the accompanying materials are made available under */ /* the terms of the Common Public License v1.0 which accompanies this */ @@ -99,6 +99,12 @@ memcpy(target, padString, maxLength); // now peform the AND operation between the two strings +// avoid warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] +// (or similar) in gcc 12 and above, due to our RexxString char stringData[4] +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif while (minLength--) { *target = *target & *source++; @@ -111,6 +117,9 @@ *target = *target & padChar; target++; } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif return retval; } @@ -168,6 +177,12 @@ memcpy(target, padString, maxLength); // now peform the AND operation between the two strings +// avoid warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] +// (or similar) in gcc 12 and above, due to our RexxString char stringData[4] +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif while (minLength--) { *target = *target | *source++; @@ -180,6 +195,9 @@ *target = *target | padChar; target++; } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif return retval; } @@ -235,6 +253,12 @@ memcpy(target, padString, maxLength); // now peform the XOR operation between the two strings +// avoid warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] +// (or similar) in gcc 12 and above, due to our RexxString char stringData[4] +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif while (minLength--) { *target = *target ^ *source++; @@ -247,6 +271,9 @@ *target = *target ^ padChar; target++; } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif return retval; } Modified: main/trunk/interpreter/classes/StringClassConversion.cpp =================================================================== --- main/trunk/interpreter/classes/StringClassConversion.cpp 2025-05-21 08:49:55 UTC (rev 12986) +++ main/trunk/interpreter/classes/StringClassConversion.cpp 2025-05-23 15:44:02 UTC (rev 12987) @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------*/ /* */ /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ -/* Copyright (c) 2005-2019 Rexx Language Association. All rights reserved. */ +/* Copyright (c) 2005-2025 Rexx Language Association. All rights reserved. */ /* */ /* This program and the accompanying materials are made available under */ /* the terms of the Common Public License v1.0 which accompanies this */ @@ -492,7 +492,16 @@ // reverse each byte using an exclusive OR while (tempSize--) { +// avoid warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] +// (or similar) in gcc 12 and above, due to our RexxString char stringData[4] +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif *scan = *scan ^ 0xff; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif scan++; } Modified: main/trunk/interpreter/classes/StringClassSub.cpp =================================================================== --- main/trunk/interpreter/classes/StringClassSub.cpp 2025-05-21 08:49:55 UTC (rev 12986) +++ main/trunk/interpreter/classes/StringClassSub.cpp 2025-05-23 15:44:02 UTC (rev 12987) @@ -459,12 +459,16 @@ // now perform the whole length copy while (length--) { -// avoid GCC warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] -// (or similar) in gcc 10 and above, due to our RexxString char stringData[4] +// avoid warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] +// (or similar) in gcc 12 and above, due to our RexxString char stringData[4] +#ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif *string++ = *end--; +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif } return retval; Modified: main/trunk/interpreter/runtime/MethodArguments.hpp =================================================================== --- main/trunk/interpreter/runtime/MethodArguments.hpp 2025-05-21 08:49:55 UTC (rev 12986) +++ main/trunk/interpreter/runtime/MethodArguments.hpp 2025-05-23 15:44:02 UTC (rev 12987) @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------*/ /* */ /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ -/* Copyright (c) 2005-2020 Rexx Language Association. All rights reserved. */ +/* Copyright (c) 2005-2025 Rexx Language Association. All rights reserved. */ /* */ /* This program and the accompanying materials are made available under */ /* the terms of the Common Public License v1.0 which accompanies this */ @@ -138,6 +138,11 @@ if (object == OREF_NULL) { missingArgument(position); + // missingArgument() will not return although, technically, it could + // and gcc 11.4 issues warning: 'this' pointer is null [-Wnonnull] when + // MutableBuffer::appendRexx calls stringArgument(OREF_NULL, ARG_ONE) + // To avoid this warning we add a return here + return GlobalNames::NULLSTRING; } return object->requiredString(position); } Modified: main/trunk/interpreter/runtime/RexxUtilCommon.cpp =================================================================== --- main/trunk/interpreter/runtime/RexxUtilCommon.cpp 2025-05-21 08:49:55 UTC (rev 12986) +++ main/trunk/interpreter/runtime/RexxUtilCommon.cpp 2025-05-23 15:44:02 UTC (rev 12987) @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------*/ /* */ /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ -/* Copyright (c) 2005-2022 Rexx Language Association. All rights reserved. */ +/* Copyright (c) 2005-2025 Rexx Language Association. All rights reserved. */ /* */ /* This program and the accompanying materials are made available under */ /* the terms of the Common Public License v1.0 which accompanies this */ @@ -203,19 +203,16 @@ // loop until we find a unique name while (true) { - char numstr[10]; - // get the random number as a set of 9 character digits - snprintf(numstr, sizeof(numstr), "%09zu", num); + size_t n = num; // now substitute our generated characters for the filler characters - int i = 9 - j; - for (int x = 0; fileTemplate[x] != 0; x++) { // if we have a filler, fill it in if (fileTemplate[x] == filler) { - buffer[x] = numstr[i++]; + buffer[x] = '0' + n % 10; + n = n / 10; } } @@ -360,7 +357,7 @@ * The file specification consists of the search string as sent by the Rexx * user, with possibly some glob characters added. * - * If the file speicfication ends in a slash ('\') or a period ('.') or two + * If the file specification ends in a (back)slash or a period ('.') or two * periods ('..'), then a wild card specification ('*') is * appended. * @@ -373,7 +370,7 @@ * named: MyFile a command of "dir MyFile." will produce a listing of "MyFile". * * In this case we want to leave the file specification alone. that is, do not - * append a "*.*". A command of "dir *." will produce a directory listing of all + * append a '*'. A command of "dir *." will produce a directory listing of all * files that do not have an extension. */ void TreeFinder::validateFileSpec() |