]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
plugins/transcend: Fix transcend-nvme.c linux kernel check patch errors and warnings
authorTokunori Ikegami <ikegami.t@gmail.com>
Sun, 4 Jun 2023 11:47:51 +0000 (20:47 +0900)
committerDaniel Wagner <wagi@monom.org>
Tue, 6 Jun 2023 09:01:09 +0000 (11:01 +0200)
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
plugins/transcend/transcend-nvme.c

index 024351f54228a9cfc21d8033109e792e26f71ec6..547fbf4ea96ee5b06615d7254c70886630eb5785 100644 (file)
@@ -21,7 +21,7 @@ static int getHealthValue(int argc, char **argv, struct command *cmd, struct plu
 {
        struct nvme_smart_log smart_log;
        char *desc = "Get nvme health percentage.";
-       int  percent_used = 0, healthvalue=0;
+       int  percent_used = 0, healthvalue = 0;
        struct nvme_dev *dev;
        int result;
 
@@ -31,59 +31,55 @@ static int getHealthValue(int argc, char **argv, struct command *cmd, struct plu
 
        result = parse_and_open(&dev, argc, argv, desc, opts);
        if (result) {
-               printf("\nDevice not found \n");;
+               printf("\nDevice not found\n");
                return -1;
        }
        result = nvme_get_log_smart(dev_fd(dev), 0xffffffff, false, &smart_log);
        if (!result) {
                printf("Transcend NVME heath value: ");
-               percent_used =smart_log.percent_used;
-               
-               if(percent_used>100 || percent_used<0)
-               {
+               percent_used = smart_log.percent_used;
+
+               if (percent_used > 100 || percent_used < 0) {
                        printf("0%%\n");
-               }
-               else
-               {
+               } else {
                        healthvalue = 100 - percent_used;
-                       printf("%d%%\n",healthvalue);
+                       printf("%d%%\n", healthvalue);
                }
-                        
        }
        dev_close(dev);
        return result;
 }
 
 static int getBadblock(int argc, char **argv, struct command *cmd, struct plugin *plugin)
 {
 
        char *desc = "Get nvme bad block number.";
        struct nvme_dev *dev;
        int result;
+
        OPT_ARGS(opts) = {
-                
                OPT_END()
        };
 
        result = parse_and_open(&dev, argc, argv, desc, opts);
        if (result) {
-               printf("\nDevice not found \n");;
+               printf("\nDevice not found\n");
                return -1;
        }
-       unsigned char data[1]={0};
+       unsigned char data[1] = {0};
        struct nvme_passthru_cmd nvmecmd;
-       memset(&nvmecmd,0,sizeof(nvmecmd));
-       nvmecmd.opcode=OP_BAD_BLOCK;
-       nvmecmd.cdw10=DW10_BAD_BLOCK;
-       nvmecmd.cdw12=DW12_BAD_BLOCK;
+
+       memset(&nvmecmd, 0, sizeof(nvmecmd));
+       nvmecmd.opcode = OP_BAD_BLOCK;
+       nvmecmd.cdw10 = DW10_BAD_BLOCK;
+       nvmecmd.cdw12 = DW12_BAD_BLOCK;
        nvmecmd.addr = (__u64)(uintptr_t)data;
        nvmecmd.data_len = 0x1;
        result = nvme_submit_admin_passthru(dev_fd(dev), &nvmecmd, NULL);
-       if(!result) {
+       if (!result) {
                int badblock  = data[0];
-               printf("Transcend NVME badblock count: %d\n",badblock);
+
+               printf("Transcend NVME badblock count: %d\n", badblock);
        }
        dev_close(dev);
        return result;