Changeset: d8b11e57606a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d8b11e57606a
Modified Files:
        common/utils/mstring.h
Branch: default
Log Message:

Simplify at the cost of some efficiency.  Hopefully compilers complain less.


diffs (35 lines):

diff --git a/common/utils/mstring.h b/common/utils/mstring.h
--- a/common/utils/mstring.h
+++ b/common/utils/mstring.h
@@ -42,30 +42,7 @@ strcpy_len(char *restrict dst, const cha
                        if ((dst[i] = src[i]) == 0)
                                return i;
                }
-               /* for correctness, the decrement isn't needed (just assigning 0
-                * to dst[n-1] would be sufficient), but to work around a too
-                * strict GNU C compiler, we do need it */
-               dst[--n] = 0;
-/* in some versions of GCC (at least gcc (Ubuntu 7.5.0-3ubuntu1~18.04)
- * 7.5.0), the error just can't be turned off when using
- * --enable-strict, so we just use the (more) expensive way of getting the
- * right answer (rescan the whole string) */
-#if !defined(__GNUC__) || __GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ > 5)
-/* This code is correct, but GCC gives a warning in certain
- * conditions, so we disable the warning temporarily.
- * The warning happens e.g. in
- *   strcpy_len(buf, "fixed string", sizeof(buf))
- * where buf is larger than the string. In that case we never get here
- * since return is executed in the loop above, but the compiler
- * complains anyway about reading out-of-bounds.
- * For GCC we use _Pragma to disable the warning (and hence error).
- * Since other compilers may warn (and hence error out) on
- * unrecognized pragmas, we use some preprocessor trickery. */
-GCC_Pragma("GCC diagnostic push")
-GCC_Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
-               return n + strlen(src + n);
-GCC_Pragma("GCC diagnostic pop")
-#endif
+               dst[n - 1] = 0;
        }
        return strlen(src);
 }
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to