Don't use asserts for parameter validation.

This commit is contained in:
Jef Driesen 2011-10-18 21:40:56 +02:00
parent 8f2e3265fe
commit bb32b13b09
4 changed files with 15 additions and 13 deletions

View File

@ -275,8 +275,9 @@ cressi_edy_device_read (device_t *abstract, unsigned int address, unsigned char
if (! device_is_cressi_edy (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
assert (address % (CRESSI_EDY_PACKET_SIZE / 4)== 0);
assert (size % CRESSI_EDY_PACKET_SIZE == 0);
if ((address % (CRESSI_EDY_PACKET_SIZE / 4) != 0) ||
(size % CRESSI_EDY_PACKET_SIZE != 0))
return DEVICE_STATUS_ERROR;
// The data transmission is split in packages
// of maximum $CRESSI_EDY_PACKET_SIZE bytes.

View File

@ -21,7 +21,6 @@
#include <string.h> // memcpy
#include <stdlib.h> // malloc, free
#include <assert.h> // assert
#include "device-private.h"
#include "oceanic_common.h"
@ -459,8 +458,9 @@ oceanic_atom2_device_read (device_t *abstract, unsigned int address, unsigned ch
if (! device_is_oceanic_atom2 (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
assert (address % PAGESIZE == 0);
assert (size % PAGESIZE == 0);
if ((address % PAGESIZE != 0) ||
(size % PAGESIZE != 0))
return DEVICE_STATUS_ERROR;
// The data transmission is split in packages
// of maximum $PAGESIZE bytes.
@ -497,8 +497,9 @@ oceanic_atom2_device_write (device_t *abstract, unsigned int address, const unsi
if (! device_is_oceanic_atom2 (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
assert (address % PAGESIZE == 0);
assert (size % PAGESIZE == 0);
if ((address % PAGESIZE != 0) ||
(size % PAGESIZE != 0))
return DEVICE_STATUS_ERROR;
// The data transmission is split in packages
// of maximum $PAGESIZE bytes.

View File

@ -21,7 +21,6 @@
#include <string.h> // memcpy
#include <stdlib.h> // malloc, free
#include <assert.h> // assert
#include "device-private.h"
#include "oceanic_common.h"
@ -394,8 +393,9 @@ oceanic_veo250_device_read (device_t *abstract, unsigned int address, unsigned c
if (! device_is_oceanic_veo250 (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
assert (address % PAGESIZE == 0);
assert (size % PAGESIZE == 0);
if ((address % PAGESIZE != 0) ||
(size % PAGESIZE != 0))
return DEVICE_STATUS_ERROR;
// The data transmission is split in packages
// of maximum $PAGESIZE bytes.

View File

@ -21,7 +21,6 @@
#include <string.h> // memcpy
#include <stdlib.h> // malloc, free
#include <assert.h> // assert
#include "device-private.h"
#include "oceanic_common.h"
@ -462,8 +461,9 @@ oceanic_vtpro_device_read (device_t *abstract, unsigned int address, unsigned ch
if (! device_is_oceanic_vtpro (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
assert (address % PAGESIZE == 0);
assert (size % PAGESIZE == 0);
if ((address % PAGESIZE != 0) ||
(size % PAGESIZE != 0))
return DEVICE_STATUS_ERROR;
// The data transmission is split in packages
// of maximum $PAGESIZE bytes.