@@ -773,7 +773,6 @@ static IOCTLEntry ioctl_entries[] = {
#define IOCTL_IGNORE(cmd) \
{ TARGET_ ## cmd, 0, #cmd },
#include "ioctls.h"
- { 0, 0, },
};
/* ??? Implement proper locking for ioctls. */
@@ -789,16 +788,17 @@ SYSCALL_IMPL(ioctl)
int target_size;
void *argptr;
- for (ie = ioctl_entries; ; ie++) {
- if (ie->target_cmd == 0) {
- gemu_log("Unsupported ioctl: cmd=0x%04x\n", cmd);
- return -TARGET_ENOSYS;
- }
+ for (ie = ioctl_entries;
+ ie < ioctl_entries + ARRAY_SIZE(ioctl_entries);
+ ie++) {
if (ie->target_cmd == cmd) {
- break;
+ goto found;
}
}
+ gemu_log("Unsupported ioctl: cmd=0x%04x\n", cmd);
+ return -TARGET_ENOSYS;
+ found:
arg_type = ie->arg_type;
if (ie->do_ioctl) {
return ie->do_ioctl(ie, buf_temp, fd, cmd, arg);
@@ -8173,7 +8173,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
void syscall_init(void)
{
- IOCTLEntry *ie;
const argtype *arg_type;
int size;
int i;
@@ -8203,8 +8202,8 @@ void syscall_init(void)
* We patch the ioctl size if necessary. We rely on the fact that
* no ioctl has all the bits at '1' in the size field.
*/
- ie = ioctl_entries;
- while (ie->target_cmd != 0) {
+ for (i = 0; i < ARRAY_SIZE(ioctl_entries); i++) {
+ IOCTLEntry *ie = &ioctl_entries[i];
if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) ==
TARGET_IOC_SIZEMASK) {
arg_type = ie->arg_type;
@@ -8228,6 +8227,5 @@ void syscall_init(void)
ie->name, ie->target_cmd, ie->host_cmd);
}
#endif
- ie++;
}
}
Iterate based on the size of the array instead. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- linux-user/syscall-ioctl.inc.c | 14 +++++++------- linux-user/syscall.c | 6 ++---- 2 files changed, 9 insertions(+), 11 deletions(-) -- 2.17.1