Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: greybus: firmware: Convert sscanf calls to strtoul

Also convert the fw_update_type and fw_timeout variables to
unsigned and update the printf specifier to %u.

The FW_MGMT_IOC_SET_TIMEOUT_MS ioctl takes an unsigned int
and checkpatch was complaining about not checking the sscanf
return values.

Signed-off-by: Michael Sartain <mikesart@fastmail.com>
Acked-by: Viresh Kumar <viresh.kumar at linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Michael Sartain and committed by
Greg Kroah-Hartman
4da14d59 afb5fdfc

+7 -5
+7 -5
drivers/staging/greybus/Documentation/firmware/firmware.c
··· 52 52 */ 53 53 54 54 #include <stdio.h> 55 + #include <stdlib.h> 55 56 #include <string.h> 56 57 #include <unistd.h> 57 58 #include <sys/ioctl.h> ··· 69 68 70 69 static const char *firmware_tag; 71 70 static const char *fwdev = FW_DEV_DEFAULT; 72 - static int fw_update_type = FW_UPDATE_TYPE_DEFAULT; 73 - static int fw_timeout = FW_TIMEOUT_DEFAULT; 71 + static unsigned int fw_update_type = FW_UPDATE_TYPE_DEFAULT; 72 + static unsigned int fw_timeout = FW_TIMEOUT_DEFAULT; 74 73 75 74 static struct fw_mgmt_ioc_get_intf_version intf_fw_info; 76 75 static struct fw_mgmt_ioc_get_backend_version backend_fw_info; ··· 205 204 int main(int argc, char *argv[]) 206 205 { 207 206 int fd, ret; 207 + char *endptr; 208 208 209 209 if (argc > 1 && 210 210 (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) { ··· 217 215 fwdev = argv[1]; 218 216 219 217 if (argc > 2) 220 - sscanf(argv[2], "%u", &fw_update_type); 218 + fw_update_type = strtoul(argv[2], &endptr, 10); 221 219 222 220 if (argc > 3) 223 221 firmware_tag = argv[3]; ··· 227 225 firmware_tag = FW_TAG_BCND_DEFAULT; 228 226 229 227 if (argc > 4) 230 - sscanf(argv[4], "%u", &fw_timeout); 228 + fw_timeout = strtoul(argv[4], &endptr, 10); 231 229 232 - printf("Trying Firmware update: fwdev: %s, type: %s, tag: %s, timeout: %d\n", 230 + printf("Trying Firmware update: fwdev: %s, type: %s, tag: %s, timeout: %u\n", 233 231 fwdev, fw_update_type == 0 ? "interface" : "backend", 234 232 firmware_tag, fw_timeout); 235 233