]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
skd: use memcpy() as a cleanup
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 13 Sep 2013 12:53:10 +0000 (15:53 +0300)
committerJens Axboe <axboe@kernel.dk>
Fri, 13 Sep 2013 17:07:41 +0000 (11:07 -0600)
The code here is copying the version to inq.driver_version but we don't
want it to be NUL terminated.  Instead we pad the rest of the array with
spaces.  It's fewer lines to use memcpy() and maybe a little nicer.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/skd_main.c

index 467ae1a3966128e6631f5ff864226c30b79b7e64..773e79370a15ab6fa9bfbb4a3389796d3b44712b 100644 (file)
@@ -2899,9 +2899,7 @@ static void skd_do_inq_page_da(struct skd_device *skdev,
                               volatile struct fit_comp_error_info *skerr,
                               uint8_t *cdb, uint8_t *buf)
 {
-       unsigned ver_byte;
        unsigned max_bytes;
-       char *ver = DRV_VER_COMPL;
        struct driver_inquiry_data inq;
        u16 val;
 
@@ -2945,12 +2943,8 @@ static void skd_do_inq_page_da(struct skd_device *skdev,
        /* Driver version, fixed lenth, padded with spaces on the right */
        inq.driver_version_length = sizeof(inq.driver_version);
        memset(&inq.driver_version, ' ', sizeof(inq.driver_version));
-       for (ver_byte = 0; ver_byte < sizeof(inq.driver_version); ver_byte++) {
-               if (ver[ver_byte] != 0)
-                       inq.driver_version[ver_byte] = ver[ver_byte];
-               else
-                       break;
-       }
+       memcpy(inq.driver_version, DRV_VER_COMPL,
+              min(sizeof(inq.driver_version), strlen(DRV_VER_COMPL)));
 
        inq.page_length = cpu_to_be16((sizeof(inq) - 4));