[Openmp-commits] [PATCH] D39756: Add const to some variables to avoid const_casts

Jonas Hahnfeld via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Nov 9 07:52:48 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL317798: Add const to some variables to avoid const_casts (authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D39756?vs=122242&id=122252#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39756

Files:
  openmp/trunk/runtime/src/kmp_settings.cpp
  openmp/trunk/runtime/src/kmp_utility.cpp


Index: openmp/trunk/runtime/src/kmp_settings.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_settings.cpp
+++ openmp/trunk/runtime/src/kmp_settings.cpp
@@ -3298,15 +3298,15 @@
     if (length > INT_MAX) {
       KMP_WARNING(LongValue, name);
     } else {
-      char *semicolon;
+      const char *semicolon;
       if (value[length - 1] == '"' || value[length - 1] == '\'')
         KMP_WARNING(UnbalancedQuotes, name);
       do {
         char sentinel;
 
-        semicolon = CCAST(char *, strchr(value, ';'));
+        semicolon = strchr(value, ';');
         if (*value && semicolon != value) {
-          char *comma = CCAST(char *, strchr(value, ','));
+          const char *comma = strchr(value, ',');
 
           if (comma) {
             ++comma;
@@ -3371,7 +3371,7 @@
   if (value) {
     length = KMP_STRLEN(value);
     if (length) {
-      char *comma = CCAST(char *, strchr(value, ','));
+      const char *comma = strchr(value, ',');
       if (value[length - 1] == '"' || value[length - 1] == '\'')
         KMP_WARNING(UnbalancedQuotes, name);
       /* get the specified scheduling style */
Index: openmp/trunk/runtime/src/kmp_utility.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_utility.cpp
+++ openmp/trunk/runtime/src/kmp_utility.cpp
@@ -96,14 +96,13 @@
     ) {
 
   double value = 0.0;
-  char const *unit = NULL;
+  char *unit = NULL;
   kmp_uint64 result = 0; /* Zero is a better unknown value than all ones. */
 
   if (frequency == NULL) {
     return result;
   }
-  value = strtod(frequency,
-                 CCAST(char **, &unit)); // strtod() does not like "const"
+  value = strtod(frequency, &unit);
   if (0 < value &&
       value <= DBL_MAX) { // Good value (not overflow, underflow, etc).
     if (strcmp(unit, "MHz") == 0) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39756.122252.patch
Type: text/x-patch
Size: 1886 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20171109/ff631354/attachment.bin>


More information about the Openmp-commits mailing list