[rtems-tools commit] Fix gcc 9 warnings

Chris Johns chrisj at rtems.org
Sat Oct 3 03:00:57 UTC 2020


Module:    rtems-tools
Branch:    4.11
Commit:    65c3922e9b01da1703b64e3d253ca1af8fb2653f
Changeset: http://git.rtems.org/rtems-tools/commit/?id=65c3922e9b01da1703b64e3d253ca1af8fb2653f

Author:    Chris Johns <chrisj at rtems.org>
Date:      Sat Oct  3 09:26:38 2020 +1000

Fix gcc 9 warnings

---

 linkers/rtems-ld.cpp       |  4 +--
 linkers/rtems-ra.cpp       |  4 +--
 linkers/rtems-rapper.cpp   |  6 ++--
 linkers/rtems-syms.cpp     |  2 +-
 linkers/rtems-tld.cpp      |  4 +--
 rtemstoolkit/ConvertUTF.c  | 79 +++++++++++++++++++++++-----------------------
 rtemstoolkit/rld-files.cpp |  2 +-
 7 files changed, 51 insertions(+), 50 deletions(-)

diff --git a/linkers/rtems-ld.cpp b/linkers/rtems-ld.cpp
index 92258df..ac0563f 100644
--- a/linkers/rtems-ld.cpp
+++ b/linkers/rtems-ld.cpp
@@ -547,14 +547,14 @@ main (int argc, char* argv[])
 
     cache.archives_end ();
   }
-  catch (rld::error re)
+  catch (rld::error& re)
   {
     std::cerr << "error: "
               << re.where << ": " << re.what
               << std::endl;
     ec = 10;
   }
-  catch (std::exception e)
+  catch (std::exception& e)
   {
     int   status;
     char* realname;
diff --git a/linkers/rtems-ra.cpp b/linkers/rtems-ra.cpp
index efd4cf9..7e8d233 100644
--- a/linkers/rtems-ra.cpp
+++ b/linkers/rtems-ra.cpp
@@ -586,14 +586,14 @@ main (int argc, char* argv[])
       }
     }
   }
-  catch (rld::error re)
+  catch (rld::error& re)
   {
     std::cerr << "error: "
               << re.where << ": " << re.what
               << std::endl;
     ec = 10;
   }
-  catch (std::exception e)
+  catch (std::exception& e)
   {
     int   status;
     char* realname;
diff --git a/linkers/rtems-rapper.cpp b/linkers/rtems-rapper.cpp
index afc301d..ae339ac 100644
--- a/linkers/rtems-rapper.cpp
+++ b/linkers/rtems-rapper.cpp
@@ -726,7 +726,7 @@ rap_show (rld::path::paths& raps,
     {
       r.load ();
     }
-    catch (rld::error re)
+    catch (rld::error& re)
     {
       std::cout << " error: "
                 << re.where << ": " << re.what
@@ -1280,14 +1280,14 @@ main (int argc, char* argv[])
     if (expand)
       rap_expander (raps, warnings);
   }
-  catch (rld::error re)
+  catch (rld::error& re)
   {
     std::cerr << "error: "
               << re.where << ": " << re.what
               << std::endl;
     ec = 10;
   }
-  catch (std::exception e)
+  catch (std::exception& e)
   {
     int   status;
     char* realname;
diff --git a/linkers/rtems-syms.cpp b/linkers/rtems-syms.cpp
index 3670188..c0064dd 100644
--- a/linkers/rtems-syms.cpp
+++ b/linkers/rtems-syms.cpp
@@ -530,7 +530,7 @@ main (int argc, char* argv[])
               << std::endl;
     ec = 10;
   }
-  catch (std::exception e)
+  catch (std::exception& e)
   {
     int   status;
     char* realname;
diff --git a/linkers/rtems-tld.cpp b/linkers/rtems-tld.cpp
index 580c4c1..65de8dc 100644
--- a/linkers/rtems-tld.cpp
+++ b/linkers/rtems-tld.cpp
@@ -1878,14 +1878,14 @@ main (int argc, char* argv[])
     }
 
   }
-  catch (rld::error re)
+  catch (rld::error& re)
   {
     std::cerr << "error: "
               << re.where << ": " << re.what
               << std::endl;
     ec = 10;
   }
-  catch (std::exception e)
+  catch (std::exception& e)
   {
     int   status;
     char* realname;
diff --git a/rtemstoolkit/ConvertUTF.c b/rtemstoolkit/ConvertUTF.c
index 9b3deeb..4263952 100644
--- a/rtemstoolkit/ConvertUTF.c
+++ b/rtemstoolkit/ConvertUTF.c
@@ -1,8 +1,8 @@
 /*
  * Copyright 2001-2004 Unicode, Inc.
- * 
+ *
  * Disclaimer
- * 
+ *
  * This source code is provided as is by Unicode, Inc. No claims are
  * made as to fitness for any particular purpose. No warranties of any
  * kind are expressed or implied. The recipient agrees to determine
@@ -10,9 +10,9 @@
  * purchased on magnetic or optical media from Unicode, Inc., the
  * sole remedy for any claim will be exchange of defective media
  * within 90 days of receipt.
- * 
+ *
  * Limitations on Rights to Redistribute This Code
- * 
+ *
  * Unicode, Inc. hereby grants the right to freely use the information
  * supplied in this file in the creation of products supporting the
  * Unicode Standard, and to make copies of this file in any form
@@ -59,7 +59,7 @@ static const UTF32 halfMask = 0x3FFUL;
 /* --------------------------------------------------------------------- */
 
 ConversionResult ConvertUTF32toUTF16 (
-	const UTF32** sourceStart, const UTF32* sourceEnd, 
+	const UTF32** sourceStart, const UTF32* sourceEnd,
 	UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
     ConversionResult result = conversionOK;
     const UTF32* source = *sourceStart;
@@ -108,7 +108,7 @@ ConversionResult ConvertUTF32toUTF16 (
 /* --------------------------------------------------------------------- */
 
 ConversionResult ConvertUTF16toUTF32 (
-	const UTF16** sourceStart, const UTF16* sourceEnd, 
+	const UTF16** sourceStart, const UTF16* sourceEnd,
 	UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
     ConversionResult result = conversionOK;
     const UTF16* source = *sourceStart;
@@ -187,7 +187,7 @@ static const char trailingBytesForUTF8[256] = {
  * This table contains as many values as there might be trailing bytes
  * in a UTF-8 sequence.
  */
-static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, 
+static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
 		     0x03C82080UL, 0xFA082080UL, 0x82082080UL };
 
 /*
@@ -212,7 +212,7 @@ static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
 /* --------------------------------------------------------------------- */
 
 ConversionResult ConvertUTF16toUTF8 (
-	const UTF16** sourceStart, const UTF16* sourceEnd, 
+	const UTF16** sourceStart, const UTF16* sourceEnd,
 	UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
     ConversionResult result = conversionOK;
     const UTF16* source = *sourceStart;
@@ -221,7 +221,7 @@ ConversionResult ConvertUTF16toUTF8 (
 	UTF32 ch;
 	unsigned short bytesToWrite = 0;
 	const UTF32 byteMask = 0xBF;
-	const UTF32 byteMark = 0x80; 
+	const UTF32 byteMark = 0x80;
 	const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
 	ch = *source++;
 	/* If we have a surrogate pair, convert to UTF32 first. */
@@ -267,10 +267,10 @@ ConversionResult ConvertUTF16toUTF8 (
 	    target -= bytesToWrite; result = targetExhausted; break;
 	}
 	switch (bytesToWrite) { /* note: everything falls through. */
-	    case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
-	    case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
-	    case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
-	    case 1: *--target =  (UTF8)(ch | firstByteMark[bytesToWrite]);
+	    case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; /* fall-thru */
+	    case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; /* fall-thru */
+	    case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; /* fall-thru */
+	    case 1: *--target =  (UTF8)(ch | firstByteMark[bytesToWrite]);    /* fall-thru */
 	}
 	target += bytesToWrite;
     }
@@ -298,9 +298,9 @@ static Boolean isLegalUTF8(const UTF8 *source, int length) {
     switch (length) {
     default: return false;
 	/* Everything else falls through when "true"... */
-    case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
-    case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
-    case 2: if ((a = (*--srcptr)) > 0xBF) return false;
+    case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; /* fall-thru */
+    case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; /* fall-thru */
+    case 2: if ((a = (*--srcptr)) > 0xBF) return false;             /* fall-thru */
 
 	switch (*source) {
 	    /* no fall-through in this inner switch */
@@ -308,10 +308,10 @@ static Boolean isLegalUTF8(const UTF8 *source, int length) {
 	    case 0xED: if (a > 0x9F) return false; break;
 	    case 0xF0: if (a < 0x90) return false; break;
 	    case 0xF4: if (a > 0x8F) return false; break;
-	    default:   if (a < 0x80) return false;
+	    default:   if (a < 0x80) return false; break;
 	}
-
-    case 1: if (*source >= 0x80 && *source < 0xC2) return false;
+    /* FALLTHRU */
+    case 1: if (*source >= 0x80 && *source < 0xC2) return false; /* fall-thru */
     }
     if (*source > 0xF4) return false;
     return true;
@@ -334,7 +334,7 @@ Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) {
 /* --------------------------------------------------------------------- */
 
 ConversionResult ConvertUTF8toUTF16 (
-	const UTF8** sourceStart, const UTF8* sourceEnd, 
+	const UTF8** sourceStart, const UTF8* sourceEnd,
 	UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
     ConversionResult result = conversionOK;
     const UTF8* source = *sourceStart;
@@ -354,12 +354,12 @@ ConversionResult ConvertUTF8toUTF16 (
 	 * The cases all fall through. See "Note A" below.
 	 */
 	switch (extraBytesToRead) {
-	    case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
-	    case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
-	    case 3: ch += *source++; ch <<= 6;
-	    case 2: ch += *source++; ch <<= 6;
-	    case 1: ch += *source++; ch <<= 6;
-	    case 0: ch += *source++;
+	    case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ /* fall-thru */
+	    case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ /* fall-thru */
+	    case 3: ch += *source++; ch <<= 6; /* fall-thru */
+	    case 2: ch += *source++; ch <<= 6; /* fall-thru */
+	    case 1: ch += *source++; ch <<= 6; /* fall-thru */
+	    case 0: ch += *source++;           /* fall-thru */
 	}
 	ch -= offsetsFromUTF8[extraBytesToRead];
 
@@ -407,7 +407,7 @@ ConversionResult ConvertUTF8toUTF16 (
 /* --------------------------------------------------------------------- */
 
 ConversionResult ConvertUTF32toUTF8 (
-	const UTF32** sourceStart, const UTF32* sourceEnd, 
+	const UTF32** sourceStart, const UTF32* sourceEnd,
 	UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
     ConversionResult result = conversionOK;
     const UTF32* source = *sourceStart;
@@ -416,7 +416,7 @@ ConversionResult ConvertUTF32toUTF8 (
 	UTF32 ch;
 	unsigned short bytesToWrite = 0;
 	const UTF32 byteMask = 0xBF;
-	const UTF32 byteMark = 0x80; 
+	const UTF32 byteMark = 0x80;
 	ch = *source++;
 	if (flags == strictConversion ) {
 	    /* UTF-16 surrogate values are illegal in UTF-32 */
@@ -438,7 +438,7 @@ ConversionResult ConvertUTF32toUTF8 (
 					    ch = UNI_REPLACEMENT_CHAR;
 					    result = sourceIllegal;
 	}
-	
+
 	target += bytesToWrite;
 	if (target > targetEnd) {
 	    --source; /* Back up source pointer! */
@@ -446,9 +446,10 @@ ConversionResult ConvertUTF32toUTF8 (
 	}
 	switch (bytesToWrite) { /* note: everything falls through. */
 	    case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
-	    case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
-	    case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
-	    case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]);
+	    /* fall-thru */
+	    case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; /* fall-thru */
+	    case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; /* fall-thru */
+	    case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]);    /* fall-thru */
 	}
 	target += bytesToWrite;
     }
@@ -460,7 +461,7 @@ ConversionResult ConvertUTF32toUTF8 (
 /* --------------------------------------------------------------------- */
 
 ConversionResult ConvertUTF8toUTF32 (
-	const UTF8** sourceStart, const UTF8* sourceEnd, 
+	const UTF8** sourceStart, const UTF8* sourceEnd,
 	UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
     ConversionResult result = conversionOK;
     const UTF8* source = *sourceStart;
@@ -480,12 +481,12 @@ ConversionResult ConvertUTF8toUTF32 (
 	 * The cases all fall through. See "Note A" below.
 	 */
 	switch (extraBytesToRead) {
-	    case 5: ch += *source++; ch <<= 6;
-	    case 4: ch += *source++; ch <<= 6;
-	    case 3: ch += *source++; ch <<= 6;
-	    case 2: ch += *source++; ch <<= 6;
-	    case 1: ch += *source++; ch <<= 6;
-	    case 0: ch += *source++;
+	    case 5: ch += *source++; ch <<= 6; /* fall-thru */
+	    case 4: ch += *source++; ch <<= 6; /* fall-thru */
+	    case 3: ch += *source++; ch <<= 6; /* fall-thru */
+	    case 2: ch += *source++; ch <<= 6; /* fall-thru */
+	    case 1: ch += *source++; ch <<= 6; /* fall-thru */
+	    case 0: ch += *source++;           /* fall-thru */
 	}
 	ch -= offsetsFromUTF8[extraBytesToRead];
 
diff --git a/rtemstoolkit/rld-files.cpp b/rtemstoolkit/rld-files.cpp
index 5bc266c..f4eefe1 100644
--- a/rtemstoolkit/rld-files.cpp
+++ b/rtemstoolkit/rld-files.cpp
@@ -253,7 +253,7 @@ namespace rld
     image::~image ()
     {
       if (references_)
-        throw rld_error_at ("references when destructing image");
+        std::cerr << "references when destructing image" << std::endl;
       if (fd_ >= 0)
         ::close (fd_);
     }



More information about the vc mailing list