Code

drbd plugin: replace atoi with strtol
authorTim Laszlo <Tim.Laszlo@magnetar.com>
Mon, 28 Jul 2014 17:00:05 +0000 (12:00 -0500)
committerTim Laszlo <Tim.Laszlo@magnetar.com>
Mon, 28 Jul 2014 17:00:05 +0000 (12:00 -0500)
src/drbd.c

index 800bf62dadd26657a429b706e2d0eefba26a92ff..2c80ca2f6fe92b4ef0181c8c12bbf550fce8841d 100644 (file)
@@ -58,7 +58,7 @@ static int drbd_init (void)
 }
 
 
-static int drbd_submit_fields (int resource,
+static int drbd_submit_fields (long int resource,
                char **fields, size_t fields_num)
 {
        char plugin_instance[DATA_MAX_NAME_LEN];
@@ -75,12 +75,12 @@ static int drbd_submit_fields (int resource,
        if (fields_num != drbd_names_num)
        {
                WARNING ("drbd plugin: Wrong number of fields for "
-                                "r%i statistics. Expected %zu, got %zu.",
+                                "r%ld statistics. Expected %zu, got %zu.",
                                 resource, drbd_names_num, fields_num);
                return (EINVAL);
        }
 
-       ssnprintf (plugin_instance, sizeof (plugin_instance), "r%i",
+       ssnprintf (plugin_instance, sizeof (plugin_instance), "r%ld",
                        resource);
 
        for (i = 0; i < drbd_names_num; i++)
@@ -120,7 +120,7 @@ static int drbd_read (void)
        FILE *fh;
        char buffer[256];
 
-       int resource = -1;
+       long int resource = -1;
        char *fields[16];
        int fields_num = 0;
 
@@ -143,7 +143,7 @@ static int drbd_read (void)
                if (isdigit(fields[0][0]))
                {
                        /* parse the resource line */
-                       resource = atoi(fields[0]);
+                       resource = strtol(fields[0], NULL, 10);
                }
                else
                {