logger: Suppress SVACE sign extension warnings 89/258489/1
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Tue, 18 May 2021 12:26:51 +0000 (14:26 +0200)
committerSylwester Nawrocki <s.nawrocki@samsung.com>
Tue, 18 May 2021 12:38:34 +0000 (14:38 +0200)
This patch suppresses SVACE warnings shown below and makes the code more
robust. The actual sign extension issue cannot happen in current code as
value of the len variable in function logger_set_tag() is limited to
LOGGER_ENTRY_MAX_PAYLOAD and create_log() is being called only with fixed
size argument values.

* SIGNED_TO_BIGGER_UNSIGNED: Assignment of a signed value which has type 'int' to a variable of a bigger integer type 'size_t'
    Sign extension at linux-rpi3/drivers/staging/android/logger.c:898

* SIGNED_TO_BIGGER_UNSIGNED: Assignment of a signed value which has type 'int' to a variable of a bigger integer type 'size_t'
    Sign extension at linux-rpi3/drivers/staging/android/logger.c:1045

Change-Id: I8646555e1a09fb0feb4c12961965aea36c80cd38
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
drivers/staging/android/logger.c

index 14fb7f738adc998595bc05fb9b3f68934960d996..ba336bd2ce3b38113669965f4f40c65ce5936156 100644 (file)
@@ -873,7 +873,7 @@ static long logger_set_prio(struct logger_writer *writer, void __user *arg)
 static long logger_set_tag(struct logger_writer *writer, void __user *arg)
 {
        struct logger_set_tag tag;
-       int len;
+       size_t len;
        char *p, *q;
 
        if (copy_from_user(&tag, arg, sizeof(struct logger_set_tag)))
@@ -1010,7 +1010,7 @@ static const struct file_operations logger_fops = {
  * Log size must must be a power of two, and greater than
  * (LOGGER_ENTRY_MAX_PAYLOAD + sizeof(struct logger_entry)).
  */
-static int __init create_log(char *log_name, int size)
+static int __init create_log(char *log_name, size_t size)
 {
        int ret = 0;
        struct logger_log *log;