Add explicit casts to improve type safety.
This commit is contained in:
parent
599827d5a3
commit
dfeea21c36
@ -17,7 +17,7 @@ test_dump_memory (const char* filename)
|
||||
device_t *device = NULL;
|
||||
|
||||
const unsigned int size = 2 * 1024 * 1024;
|
||||
unsigned char *data = malloc (size * sizeof (unsigned char));
|
||||
unsigned char *data = (unsigned char *) malloc (size * sizeof (unsigned char));
|
||||
if (data == NULL)
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
memset (data, 0, size * sizeof (unsigned char));
|
||||
|
||||
@ -133,7 +133,7 @@ irda_socket_open (irda **out)
|
||||
return -1; // EINVAL (Invalid argument)
|
||||
|
||||
// Allocate memory.
|
||||
struct irda *device = malloc (sizeof (struct irda));
|
||||
struct irda *device = (struct irda *) malloc (sizeof (struct irda));
|
||||
if (device == NULL) {
|
||||
TRACE ("malloc");
|
||||
return -1; // ENOMEM (Not enough space)
|
||||
|
||||
@ -142,7 +142,7 @@ oceanic_atom2_device_open (device_t **out, const char* name)
|
||||
return DEVICE_STATUS_ERROR;
|
||||
|
||||
// Allocate memory.
|
||||
oceanic_atom2_device_t *device = malloc (sizeof (oceanic_atom2_device_t));
|
||||
oceanic_atom2_device_t *device = (oceanic_atom2_device_t *) malloc (sizeof (oceanic_atom2_device_t));
|
||||
if (device == NULL) {
|
||||
WARNING ("Failed to allocate memory.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
|
||||
@ -45,7 +45,7 @@ reefnet_sensuspro_device_open (device_t **out, const char* name)
|
||||
return DEVICE_STATUS_ERROR;
|
||||
|
||||
// Allocate memory.
|
||||
reefnet_sensuspro_device_t *device = malloc (sizeof (reefnet_sensuspro_device_t));
|
||||
reefnet_sensuspro_device_t *device = (reefnet_sensuspro_device_t *) malloc (sizeof (reefnet_sensuspro_device_t));
|
||||
if (device == NULL) {
|
||||
WARNING ("Failed to allocate memory.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
|
||||
@ -50,7 +50,7 @@ reefnet_sensusultra_device_open (device_t **out, const char* name)
|
||||
return DEVICE_STATUS_ERROR;
|
||||
|
||||
// Allocate memory.
|
||||
reefnet_sensusultra_device_t *device = malloc (sizeof (reefnet_sensusultra_device_t));
|
||||
reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t *) malloc (sizeof (reefnet_sensusultra_device_t));
|
||||
if (device == NULL) {
|
||||
WARNING ("Failed to allocate memory.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
@ -627,7 +627,7 @@ reefnet_sensusultra_device_foreach (device_t *abstract, dive_callback_t callback
|
||||
if (! device_is_reefnet_sensusultra (abstract))
|
||||
return DEVICE_STATUS_TYPE_MISMATCH;
|
||||
|
||||
unsigned char *data = malloc (REEFNET_SENSUSULTRA_MEMORY_DATA_SIZE * sizeof (unsigned char));
|
||||
unsigned char *data = (unsigned char *) malloc (REEFNET_SENSUSULTRA_MEMORY_DATA_SIZE * sizeof (unsigned char));
|
||||
if (data == NULL) {
|
||||
WARNING ("Memory allocation error.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
|
||||
@ -63,7 +63,7 @@ serial_open (serial** out, const char* name)
|
||||
return -1; // EINVAL (Invalid argument)
|
||||
|
||||
// Allocate memory.
|
||||
struct serial *device = malloc (sizeof (struct serial));
|
||||
struct serial *device = (struct serial *) malloc (sizeof (struct serial));
|
||||
if (device == NULL) {
|
||||
TRACE ("malloc");
|
||||
return -1; // ENOMEM (Not enough space)
|
||||
|
||||
@ -71,7 +71,7 @@ serial_open (serial** out, const char* name)
|
||||
return -1; // ERROR_INVALID_PARAMETER (The parameter is incorrect)
|
||||
|
||||
// Allocate memory.
|
||||
struct serial *device = malloc (sizeof (struct serial));
|
||||
struct serial *device = (struct serial *) malloc (sizeof (struct serial));
|
||||
if (device == NULL) {
|
||||
TRACE ("malloc");
|
||||
return -1; // ERROR_OUTOFMEMORY (Not enough storage is available to complete this operation)
|
||||
|
||||
@ -50,7 +50,7 @@ suunto_d9_device_open (device_t **out, const char* name)
|
||||
return DEVICE_STATUS_ERROR;
|
||||
|
||||
// Allocate memory.
|
||||
suunto_d9_device_t *device = malloc (sizeof (suunto_d9_device_t));
|
||||
suunto_d9_device_t *device = (suunto_d9_device_t *) malloc (sizeof (suunto_d9_device_t));
|
||||
if (device == NULL) {
|
||||
WARNING ("Failed to allocate memory.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
|
||||
@ -45,7 +45,7 @@ suunto_eon_device_open (device_t **out, const char* name)
|
||||
return DEVICE_STATUS_ERROR;
|
||||
|
||||
// Allocate memory.
|
||||
suunto_eon_device_t *device = malloc (sizeof (suunto_eon_device_t));
|
||||
suunto_eon_device_t *device = (suunto_eon_device_t *) malloc (sizeof (suunto_eon_device_t));
|
||||
if (device == NULL) {
|
||||
WARNING ("Failed to allocate memory.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
|
||||
@ -48,7 +48,7 @@ suunto_vyper_device_open (device_t **out, const char* name)
|
||||
return DEVICE_STATUS_ERROR;
|
||||
|
||||
// Allocate memory.
|
||||
suunto_vyper_device_t *device = malloc (sizeof (suunto_vyper_device_t));
|
||||
suunto_vyper_device_t *device = (suunto_vyper_device_t *) malloc (sizeof (suunto_vyper_device_t));
|
||||
if (device == NULL) {
|
||||
WARNING ("Failed to allocate memory.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
|
||||
@ -50,7 +50,7 @@ suunto_vyper2_device_open (device_t **out, const char* name)
|
||||
return DEVICE_STATUS_ERROR;
|
||||
|
||||
// Allocate memory.
|
||||
suunto_vyper2_device_t *device = malloc (sizeof (suunto_vyper2_device_t));
|
||||
suunto_vyper2_device_t *device = (suunto_vyper2_device_t *) malloc (sizeof (suunto_vyper2_device_t));
|
||||
if (device == NULL) {
|
||||
WARNING ("Failed to allocate memory.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
|
||||
@ -49,7 +49,7 @@ uwatec_aladin_device_open (device_t **out, const char* name)
|
||||
return DEVICE_STATUS_ERROR;
|
||||
|
||||
// Allocate memory.
|
||||
uwatec_aladin_device_t *device = malloc (sizeof (uwatec_aladin_device_t));
|
||||
uwatec_aladin_device_t *device = (uwatec_aladin_device_t *) malloc (sizeof (uwatec_aladin_device_t));
|
||||
if (device == NULL) {
|
||||
WARNING ("Failed to allocate memory.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
|
||||
@ -49,7 +49,7 @@ uwatec_memomouse_device_open (device_t **out, const char* name)
|
||||
return DEVICE_STATUS_ERROR;
|
||||
|
||||
// Allocate memory.
|
||||
uwatec_memomouse_device_t *device = malloc (sizeof (uwatec_memomouse_device_t));
|
||||
uwatec_memomouse_device_t *device = (uwatec_memomouse_device_t *) malloc (sizeof (uwatec_memomouse_device_t));
|
||||
if (device == NULL) {
|
||||
WARNING ("Failed to allocate memory.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
@ -276,7 +276,7 @@ uwatec_memomouse_read_packet_inner (uwatec_memomouse_device_t *device, unsigned
|
||||
progress_event (progress, DEVICE_EVENT_PROGRESS, length);
|
||||
|
||||
// Allocate memory for the entire package.
|
||||
unsigned char *buffer = malloc (total * sizeof (unsigned char));
|
||||
unsigned char *buffer = (unsigned char *) malloc (total * sizeof (unsigned char));
|
||||
if (package == NULL) {
|
||||
WARNING ("Memory allocation error.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
|
||||
@ -71,7 +71,7 @@ uwatec_smart_device_open (device_t **out)
|
||||
return DEVICE_STATUS_ERROR;
|
||||
|
||||
// Allocate memory.
|
||||
uwatec_smart_device_t *device = malloc (sizeof (uwatec_smart_device_t));
|
||||
uwatec_smart_device_t *device = (uwatec_smart_device_t *) malloc (sizeof (uwatec_smart_device_t));
|
||||
if (device == NULL) {
|
||||
WARNING ("Failed to allocate memory.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
@ -332,7 +332,7 @@ uwatec_smart_dump (uwatec_smart_device_t *device, unsigned char *data[], unsigne
|
||||
if (length == 0)
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
|
||||
unsigned char *package = malloc (length * sizeof (unsigned char));
|
||||
unsigned char *package = (unsigned char *) malloc (length * sizeof (unsigned char));
|
||||
if (package == NULL) {
|
||||
WARNING ("Memory allocation error.");
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user