From dfeea21c3612dee12077966a29e0070251563172 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Wed, 3 Sep 2008 08:51:07 +0000 Subject: [PATCH] Add explicit casts to improve type safety. --- examples/uwatec_smart_test.c | 2 +- src/irda.c | 2 +- src/oceanic_atom2.c | 2 +- src/reefnet_sensuspro.c | 2 +- src/reefnet_sensusultra.c | 4 ++-- src/serial_posix.c | 2 +- src/serial_win32.c | 2 +- src/suunto_d9.c | 2 +- src/suunto_eon.c | 2 +- src/suunto_vyper.c | 2 +- src/suunto_vyper2.c | 2 +- src/uwatec_aladin.c | 2 +- src/uwatec_memomouse.c | 4 ++-- src/uwatec_smart.c | 4 ++-- 14 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/uwatec_smart_test.c b/examples/uwatec_smart_test.c index cc3886f..dce70c0 100644 --- a/examples/uwatec_smart_test.c +++ b/examples/uwatec_smart_test.c @@ -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)); diff --git a/src/irda.c b/src/irda.c index f7f3ec1..e317e82 100644 --- a/src/irda.c +++ b/src/irda.c @@ -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) diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index eca5934..c238270 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -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; diff --git a/src/reefnet_sensuspro.c b/src/reefnet_sensuspro.c index 642e359..464f9fb 100644 --- a/src/reefnet_sensuspro.c +++ b/src/reefnet_sensuspro.c @@ -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; diff --git a/src/reefnet_sensusultra.c b/src/reefnet_sensusultra.c index da4fcaf..6a58ee0 100644 --- a/src/reefnet_sensusultra.c +++ b/src/reefnet_sensusultra.c @@ -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; diff --git a/src/serial_posix.c b/src/serial_posix.c index 918e4b5..87ef5ea 100644 --- a/src/serial_posix.c +++ b/src/serial_posix.c @@ -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) diff --git a/src/serial_win32.c b/src/serial_win32.c index 29ba230..edf1ed7 100644 --- a/src/serial_win32.c +++ b/src/serial_win32.c @@ -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) diff --git a/src/suunto_d9.c b/src/suunto_d9.c index ab32b5f..63c9944 100644 --- a/src/suunto_d9.c +++ b/src/suunto_d9.c @@ -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; diff --git a/src/suunto_eon.c b/src/suunto_eon.c index 610cbfb..dec8c1a 100644 --- a/src/suunto_eon.c +++ b/src/suunto_eon.c @@ -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; diff --git a/src/suunto_vyper.c b/src/suunto_vyper.c index 174ccc8..0202b2f 100644 --- a/src/suunto_vyper.c +++ b/src/suunto_vyper.c @@ -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; diff --git a/src/suunto_vyper2.c b/src/suunto_vyper2.c index 2bd3d90..a65134a 100644 --- a/src/suunto_vyper2.c +++ b/src/suunto_vyper2.c @@ -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; diff --git a/src/uwatec_aladin.c b/src/uwatec_aladin.c index 6f3d2bf..701b48c 100644 --- a/src/uwatec_aladin.c +++ b/src/uwatec_aladin.c @@ -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; diff --git a/src/uwatec_memomouse.c b/src/uwatec_memomouse.c index 9de99fc..cb95e74 100644 --- a/src/uwatec_memomouse.c +++ b/src/uwatec_memomouse.c @@ -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; diff --git a/src/uwatec_smart.c b/src/uwatec_smart.c index f9c6a6a..b4dd9dd 100644 --- a/src/uwatec_smart.c +++ b/src/uwatec_smart.c @@ -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;