usb: fix unbound stack warning for inotify_watchfn

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1457503640-31473-1-git-send-email-peterx@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
master
Peter Xu 2016-03-09 14:07:20 +08:00 committed by Gerd Hoffmann
parent e3d60bc7c6
commit f34d57d359
1 changed files with 2 additions and 3 deletions

View File

@ -433,12 +433,11 @@ static void inotify_watchfn(void *arg)
MTPState *s = arg;
ssize_t bytes;
/* From the man page: atleast one event can be read */
int len = sizeof(struct inotify_event) + NAME_MAX + 1;
int pos;
char buf[len];
char buf[sizeof(struct inotify_event) + NAME_MAX + 1];
for (;;) {
bytes = read(s->inotifyfd, buf, len);
bytes = read(s->inotifyfd, buf, sizeof(buf));
pos = 0;
if (bytes <= 0) {