tist: Fix initializing of variable
authorSamuel Ortiz <sameo@linux.intel.com>
Thu, 17 Mar 2011 16:37:20 +0000 (17:37 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 17 Mar 2011 16:37:20 +0000 (17:37 +0100)
sizeof(char []) is a pointer size.

Reported by: DJ Cozatt <ygdrasil@comcast.net>

plugins/tist.c

index 28498b6..b8c89cf 100644 (file)
@@ -115,14 +115,14 @@ static int read_baud_rate(unsigned long *baud)
        return err;
 }
 
-static int read_uart_name(char uart_name[])
+static int read_uart_name(char uart_name[], size_t uart_name_len)
 {
        int err;
        FILE *f;
 
        DBG("");
 
-       memset(uart_name, 0, sizeof(uart_name));
+       memset(uart_name, 0, uart_name_len);
 
        f = fopen(TIST_SYSFS_UART, "r");
        if (f == NULL)
@@ -510,7 +510,7 @@ static int tist_init(void)
        int fd, err;
        gsize len;
 
-       err = read_uart_name(uart_dev_name);
+       err = read_uart_name(uart_dev_name, sizeof(uart_dev_name));
        if (err < 0) {
                connman_error("Could not read the UART name");
                return err;