coverity appeasement - redundant check
[minix.git] / kernel / arch / i386 / do_readbios.c
blob3f162570fe44ff691dfdfb547720dd84634151f6
1 /* The kernel call implemented in this file:
2 * m_type: SYS_READBIOS
4 * The parameters for this kernel call are:
5 * m2_i1: RDB_SIZE number of bytes to copy
6 * m2_l1: RDB_ADDR absolute address in BIOS area
7 * m2_p1: RDB_BUF buffer address in requesting process
8 */
10 #include "kernel/system.h"
11 #include <minix/type.h>
13 /*===========================================================================*
14 * do_readbios *
15 *===========================================================================*/
16 int do_readbios(struct proc * caller, message * m_ptr)
18 struct vir_addr src, dst;
19 vir_bytes len = m_ptr->RDB_SIZE, limit;
21 src.offset = m_ptr->RDB_ADDR;
22 dst.offset = (vir_bytes) m_ptr->RDB_BUF;
23 src.proc_nr_e = NONE;
24 dst.proc_nr_e = m_ptr->m_source;
26 limit = src.offset + len - 1;
28 #define VINRANGE(v, a, b) ((a) <= (v) && (v) <= (b))
29 #define SUBRANGE(a,b,c,d) (VINRANGE((a), (c), (d)) && VINRANGE((b),(c),(d)))
30 #define USERRANGE(a, b) SUBRANGE(src.offset, limit, (a), (b))
32 if(!USERRANGE(BIOS_MEM_BEGIN, BIOS_MEM_END) &&
33 !USERRANGE(BASE_MEM_TOP, UPPER_MEM_END))
34 return EPERM;
36 return virtual_copy_vmcheck(caller, &src, &dst, m_ptr->RDB_SIZE);