]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
* elf/dl-tunables.c (tunable_set_val_if_valid_range): Split into ...
authorDJ Delorie <dj@delorie.com>
Sat, 21 Jan 2017 00:52:52 +0000 (19:52 -0500)
committerDJ Delorie <dj@delorie.com>
Sat, 21 Jan 2017 00:55:53 +0000 (19:55 -0500)
(tunable_set_val_if_valid_range_signed) ... this, and ...
(tunable_set_val_if_valid_range_unsigned) ... this.
(tunable_initialize): Call the correct one of the above based on type.

ChangeLog
elf/dl-tunables.c

index a113ad821d5553b1f4974c010e3d85e7c6251972..1518c7f9adbff35dd4e650cb998baeb725bc3d67 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-01-20  DJ Delorie  <dj@redhat.com>
+
+       * elf/dl-tunables.c (tunable_set_val_if_valid_range): Split into ...
+       (tunable_set_val_if_valid_range_signed) ... this, and ...
+       (tunable_set_val_if_valid_range_unsigned) ... this.
+       (tunable_initialize): Call the correct one of the above based on type.
+
 2017-01-20  Joseph Myers  <joseph@codesourcery.com>
 
        * sysdeps/hppa/fpu/libm-test-ulps: Remove *_tonearest entries.
index ba5246a099f2cbee6b71886f362268c76f42d628..cbf4c8e8f21858be43da5a0322e5324141913e4e 100644 (file)
@@ -172,10 +172,10 @@ tunables_strtoul (const char *nptr)
    explicit constraints of the tunable or with the implicit constraints of its
    type.  */
 static void
-tunable_set_val_if_valid_range (tunable_t *cur, const char *strval,
+tunable_set_val_if_valid_range_signed (tunable_t *cur, const char *strval,
                                int64_t default_min, int64_t default_max)
 {
-  int64_t val = tunables_strtoul (strval);
+  int64_t val = (int64_t) tunables_strtoul (strval);
 
   int64_t min = cur->type.min;
   int64_t max = cur->type.max;
@@ -193,6 +193,28 @@ tunable_set_val_if_valid_range (tunable_t *cur, const char *strval,
     }
 }
 
+static void
+tunable_set_val_if_valid_range_unsigned (tunable_t *cur, const char *strval,
+                                        uint64_t default_min, uint64_t default_max)
+{
+  uint64_t val = (uint64_t) tunables_strtoul (strval);
+
+  uint64_t min = cur->type.min;
+  uint64_t max = cur->type.max;
+
+  if (min == max)
+    {
+      min = default_min;
+      max = default_max;
+    }
+
+  if (val >= min && val <= max)
+    {
+      cur->val.numval = val;
+      cur->strval = strval;
+    }
+}
+
 /* Validate range of the input value and initialize the tunable CUR if it looks
    good.  */
 static void
@@ -202,12 +224,12 @@ tunable_initialize (tunable_t *cur, const char *strval)
     {
     case TUNABLE_TYPE_INT_32:
        {
-         tunable_set_val_if_valid_range (cur, strval, INT32_MIN, INT32_MAX);
+         tunable_set_val_if_valid_range_signed (cur, strval, INT32_MIN, INT32_MAX);
          break;
        }
     case TUNABLE_TYPE_SIZE_T:
        {
-         tunable_set_val_if_valid_range (cur, strval, 0, SIZE_MAX);
+         tunable_set_val_if_valid_range_unsigned (cur, strval, 0, SIZE_MAX);
          break;
        }
     case TUNABLE_TYPE_STRING: