Commit b4e237aae774a6dd3de2c3db9f87012d48ab6716
1 parent
60cbfb95
Suppress a -Werror=format-security warning
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6135 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
11 additions
and
7 deletions
usb-linux.c
... | ... | @@ -1163,7 +1163,8 @@ static int usb_host_read_file(char *line, size_t line_size, const char *device_f |
1163 | 1163 | int ret = 0; |
1164 | 1164 | char filename[PATH_MAX]; |
1165 | 1165 | |
1166 | - snprintf(filename, PATH_MAX, device_file, device_name); | |
1166 | + snprintf(filename, PATH_MAX, USBSYSBUS_PATH "/devices/%s/%s", device_name, | |
1167 | + device_file); | |
1167 | 1168 | f = fopen(filename, "r"); |
1168 | 1169 | if (f) { |
1169 | 1170 | fgets(line, line_size, f); |
... | ... | @@ -1205,27 +1206,30 @@ static int usb_host_scan_sys(void *opaque, USBScanFunc *func) |
1205 | 1206 | tmpstr += 3; |
1206 | 1207 | bus_num = atoi(tmpstr); |
1207 | 1208 | |
1208 | - if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/devnum", de->d_name)) | |
1209 | + if (!usb_host_read_file(line, sizeof(line), "devnum", de->d_name)) | |
1209 | 1210 | goto the_end; |
1210 | 1211 | if (sscanf(line, "%d", &addr) != 1) |
1211 | 1212 | goto the_end; |
1212 | 1213 | |
1213 | - if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/bDeviceClass", de->d_name)) | |
1214 | + if (!usb_host_read_file(line, sizeof(line), "bDeviceClass", | |
1215 | + de->d_name)) | |
1214 | 1216 | goto the_end; |
1215 | 1217 | if (sscanf(line, "%x", &class_id) != 1) |
1216 | 1218 | goto the_end; |
1217 | 1219 | |
1218 | - if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/idVendor", de->d_name)) | |
1220 | + if (!usb_host_read_file(line, sizeof(line), "idVendor", de->d_name)) | |
1219 | 1221 | goto the_end; |
1220 | 1222 | if (sscanf(line, "%x", &vendor_id) != 1) |
1221 | 1223 | goto the_end; |
1222 | 1224 | |
1223 | - if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/idProduct", de->d_name)) | |
1225 | + if (!usb_host_read_file(line, sizeof(line), "idProduct", | |
1226 | + de->d_name)) | |
1224 | 1227 | goto the_end; |
1225 | 1228 | if (sscanf(line, "%x", &product_id) != 1) |
1226 | 1229 | goto the_end; |
1227 | 1230 | |
1228 | - if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/product", de->d_name)) { | |
1231 | + if (!usb_host_read_file(line, sizeof(line), "product", | |
1232 | + de->d_name)) { | |
1229 | 1233 | *product_name = 0; |
1230 | 1234 | } else { |
1231 | 1235 | if (strlen(line) > 0) |
... | ... | @@ -1233,7 +1237,7 @@ static int usb_host_scan_sys(void *opaque, USBScanFunc *func) |
1233 | 1237 | pstrcpy(product_name, sizeof(product_name), line); |
1234 | 1238 | } |
1235 | 1239 | |
1236 | - if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/speed", de->d_name)) | |
1240 | + if (!usb_host_read_file(line, sizeof(line), "speed", de->d_name)) | |
1237 | 1241 | goto the_end; |
1238 | 1242 | if (!strcmp(line, "480\n")) |
1239 | 1243 | speed = USB_SPEED_HIGH; | ... | ... |