config: fix OB1, describe config errors
[collectd.git] / src / gpu_nvml.c
index a41d601..b34d80d 100644 (file)
@@ -31,8 +31,7 @@ static char *nv_errline = "";
 #define WRAPGAUGE(x) ((value_t){.gauge = (gauge_t)(x)})
 
 static const char *config_keys[] = {
-    "GPUIndex",
-    "IgnoreSelected",
+    "GPUIndex", "IgnoreSelected",
 };
 static const unsigned int n_config_keys = STATIC_ARRAY_SIZE(config_keys);
 
@@ -49,9 +48,11 @@ static int nvml_config(const char *key, const char *value) {
   if (strcasecmp(key, config_keys[0]) == 0) {
     device_ix = strtoul(value, &eptr, 10);
     if (eptr == value) {
+      ERROR("Failed to parse GPUIndex value \"%s\"", value);
       return -1;
     }
-    if (device_ix > 64) {
+    if (device_ix >= 64) {
+      ERROR("At most 64 GPUs (0 <= GPUIndex < 64) are supported!");
       return -2;
     }
     conf_match_mask |= (1 << device_ix);
@@ -59,6 +60,7 @@ static int nvml_config(const char *key, const char *value) {
     if
       IS_TRUE(value) { conf_mask_is_exclude = 1; }
   } else {
+    ERROR("Unrecognized config option %s", key);
     return -10;
   }
 
@@ -175,7 +177,7 @@ static int nvml_read(void) {
 
   return 0;
 
-  // Failures here indicate serious misconfiguration; we bail out totally.
+// Failures here indicate serious misconfiguration; we bail out totally.
 catch_nocount:
   ERROR("Failed to enumerate NVIDIA GPUs (\"%s\" returned %d)", nv_errline,
         nv_status);