]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - monitor.c
Define sysfs max buffer size
[thirdparty/mdadm.git] / monitor.c
index 820a93d0ceaf6aa6fc44618a14da3d3e136107c1..f54d07b24f591822df81135f731b1368d0c2350a 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -81,10 +81,10 @@ static int read_attr(char *buf, int len, int fd)
 
 static void read_resync_start(int fd, unsigned long long *v)
 {
-       char buf[30];
+       char buf[SYSFS_MAX_BUF_SIZE];
        int n;
 
-       n = read_attr(buf, 30, fd);
+       n = read_attr(buf, sizeof(buf), fd);
        if (n <= 0) {
                dprintf("Failed to read resync_start (%d)\n", fd);
                return;
@@ -98,11 +98,11 @@ static void read_resync_start(int fd, unsigned long long *v)
 static unsigned long long read_sync_completed(int fd)
 {
        unsigned long long val;
-       char buf[50];
+       char buf[SYSFS_MAX_BUF_SIZE];
        int n;
        char *ep;
 
-       n = read_attr(buf, 50, fd);
+       n = read_attr(buf, sizeof(buf), fd);
 
        if (n <= 0)
                return 0;
@@ -115,8 +115,8 @@ static unsigned long long read_sync_completed(int fd)
 
 static enum array_state read_state(int fd)
 {
-       char buf[20];
-       int n = read_attr(buf, 20, fd);
+       char buf[SYSFS_MAX_BUF_SIZE];
+       int n = read_attr(buf, sizeof(buf), fd);
 
        if (n <= 0)
                return bad_word;
@@ -125,8 +125,8 @@ static enum array_state read_state(int fd)
 
 static enum sync_action read_action( int fd)
 {
-       char buf[20];
-       int n = read_attr(buf, 20, fd);
+       char buf[SYSFS_MAX_BUF_SIZE];
+       int n = read_attr(buf, sizeof(buf), fd);
 
        if (n <= 0)
                return bad_action;
@@ -135,7 +135,7 @@ static enum sync_action read_action( int fd)
 
 int read_dev_state(int fd)
 {
-       char buf[100];
+       char buf[SYSFS_MAX_BUF_SIZE];
        int n = read_attr(buf, sizeof(buf), fd);
        char *cp;
        int rv = 0;
@@ -595,7 +595,7 @@ static int read_and_act(struct active_array *a, fd_set *fds)
                 */
                if ((a->curr_action != reshape) &&
                    (a->prev_action == reshape)) {
-                       char buf[40];
+                       char buf[SYSFS_MAX_BUF_SIZE];
                        if ((sysfs_get_str(&a->info, NULL,
                                          "reshape_position",
                                          buf,