Fix some casts with constant pointers

Casting away the const qualifier generates a compiler warning which can
easily be avoided by preserving the const qualifier.
This commit is contained in:
Jef Driesen 2017-11-24 20:58:21 +01:00
parent 91f5b34ae5
commit 68380b2ec0
9 changed files with 13 additions and 13 deletions

View File

@ -142,7 +142,7 @@ sample_cb (dc_sample_type_t type, dc_sample_value_t value, void *userdata)
case DC_SAMPLE_VENDOR: case DC_SAMPLE_VENDOR:
fprintf (sampledata->ostream, " <vendor type=\"%u\" size=\"%u\">", value.vendor.type, value.vendor.size); fprintf (sampledata->ostream, " <vendor type=\"%u\" size=\"%u\">", value.vendor.type, value.vendor.size);
for (unsigned int i = 0; i < value.vendor.size; ++i) for (unsigned int i = 0; i < value.vendor.size; ++i)
fprintf (sampledata->ostream, "%02X", ((unsigned char *) value.vendor.data)[i]); fprintf (sampledata->ostream, "%02X", ((const unsigned char *) value.vendor.data)[i]);
fprintf (sampledata->ostream, "</vendor>\n"); fprintf (sampledata->ostream, "</vendor>\n");
break; break;
case DC_SAMPLE_SETPOINT: case DC_SAMPLE_SETPOINT:

View File

@ -571,7 +571,7 @@ dc_bluetooth_write (dc_bluetooth_t *device, const void *data, size_t size, size_
break; // Timeout. break; // Timeout.
} }
s_ssize_t n = send (device->fd, (char*) data + nbytes, size - nbytes, 0); s_ssize_t n = send (device->fd, (const char *) data + nbytes, size - nbytes, 0);
if (n < 0) { if (n < 0) {
s_errcode_t errcode = S_ERRNO; s_errcode_t errcode = S_ERRNO;
if (errcode == S_EINTR || errcode == S_EAGAIN) if (errcode == S_EINTR || errcode == S_EAGAIN)
@ -591,7 +591,7 @@ dc_bluetooth_write (dc_bluetooth_t *device, const void *data, size_t size, size_
} }
out: out:
HEXDUMP (device->context, DC_LOGLEVEL_INFO, "Write", (unsigned char *) data, nbytes); HEXDUMP (device->context, DC_LOGLEVEL_INFO, "Write", (const unsigned char *) data, nbytes);
out_invalidargs: out_invalidargs:
if (actual) if (actual)

View File

@ -408,7 +408,7 @@ dc_device_close (dc_device_t *device)
void void
device_event_emit (dc_device_t *device, dc_event_type_t event, const void *data) device_event_emit (dc_device_t *device, dc_event_type_t event, const void *data)
{ {
dc_event_progress_t *progress = (dc_event_progress_t *) data; const dc_event_progress_t *progress = (const dc_event_progress_t *) data;
// Check the event data for errors. // Check the event data for errors.
switch (event) { switch (event) {
@ -436,10 +436,10 @@ device_event_emit (dc_device_t *device, dc_event_type_t event, const void *data)
// Cache the event data. // Cache the event data.
switch (event) { switch (event) {
case DC_EVENT_DEVINFO: case DC_EVENT_DEVINFO:
device->devinfo = *(dc_event_devinfo_t *) data; device->devinfo = *(const dc_event_devinfo_t *) data;
break; break;
case DC_EVENT_CLOCK: case DC_EVENT_CLOCK:
device->clock = *(dc_event_clock_t *) data; device->clock = *(const dc_event_clock_t *) data;
break; break;
default: default:
break; break;

View File

@ -535,7 +535,7 @@ dc_irda_write (dc_irda_t *device, const void *data, size_t size, size_t *actual)
break; // Timeout. break; // Timeout.
} }
s_ssize_t n = send (device->fd, (char*) data + nbytes, size - nbytes, 0); s_ssize_t n = send (device->fd, (const char *) data + nbytes, size - nbytes, 0);
if (n < 0) { if (n < 0) {
s_errcode_t errcode = S_ERRNO; s_errcode_t errcode = S_ERRNO;
if (errcode == S_EINTR || errcode == S_EAGAIN) if (errcode == S_EINTR || errcode == S_EAGAIN)
@ -555,7 +555,7 @@ dc_irda_write (dc_irda_t *device, const void *data, size_t size, size_t *actual)
} }
out: out:
HEXDUMP (device->context, DC_LOGLEVEL_INFO, "Write", (unsigned char *) data, nbytes); HEXDUMP (device->context, DC_LOGLEVEL_INFO, "Write", (const unsigned char *) data, nbytes);
out_invalidargs: out_invalidargs:
if (actual) if (actual)

View File

@ -30,7 +30,7 @@
#include "rbstream.h" #include "rbstream.h"
#include "array.h" #include "array.h"
#define VTABLE(abstract) ((oceanic_common_device_vtable_t *) abstract->vtable) #define VTABLE(abstract) ((const oceanic_common_device_vtable_t *) abstract->vtable)
#define RB_LOGBOOK_DISTANCE(a,b,l) ringbuffer_distance (a, b, 0, l->rb_logbook_begin, l->rb_logbook_end) #define RB_LOGBOOK_DISTANCE(a,b,l) ringbuffer_distance (a, b, 0, l->rb_logbook_begin, l->rb_logbook_end)
#define RB_LOGBOOK_INCR(a,b,l) ringbuffer_increment (a, b, l->rb_logbook_begin, l->rb_logbook_end) #define RB_LOGBOOK_INCR(a,b,l) ringbuffer_increment (a, b, l->rb_logbook_begin, l->rb_logbook_end)

View File

@ -753,7 +753,7 @@ dc_serial_write (dc_serial_t *device, const void *data, size_t size, size_t *act
} }
out: out:
HEXDUMP (device->context, DC_LOGLEVEL_INFO, "Write", (unsigned char *) data, nbytes); HEXDUMP (device->context, DC_LOGLEVEL_INFO, "Write", (const unsigned char *) data, nbytes);
out_invalidargs: out_invalidargs:
if (actual) if (actual)

View File

@ -500,7 +500,7 @@ dc_serial_write (dc_serial_t *device, const void *data, size_t size, size_t *act
} }
out: out:
HEXDUMP (device->context, DC_LOGLEVEL_INFO, "Write", (unsigned char *) data, dwWritten); HEXDUMP (device->context, DC_LOGLEVEL_INFO, "Write", (const unsigned char *) data, dwWritten);
out_invalidargs: out_invalidargs:
if (actual) if (actual)

View File

@ -38,7 +38,7 @@
#define RB_PROFILE_DISTANCE(l,a,b,m) ringbuffer_distance (a, b, m, l->rb_profile_begin, l->rb_profile_end) #define RB_PROFILE_DISTANCE(l,a,b,m) ringbuffer_distance (a, b, m, l->rb_profile_begin, l->rb_profile_end)
#define VTABLE(abstract) ((suunto_common2_device_vtable_t *) abstract->vtable) #define VTABLE(abstract) ((const suunto_common2_device_vtable_t *) abstract->vtable)
void void
suunto_common2_device_init (suunto_common2_device_t *device) suunto_common2_device_init (suunto_common2_device_t *device)

View File

@ -523,7 +523,7 @@ out:
} }
#endif #endif
HEXDUMP (usbhid->context, DC_LOGLEVEL_INFO, "Write", (unsigned char *) data, nbytes); HEXDUMP (usbhid->context, DC_LOGLEVEL_INFO, "Write", (const unsigned char *) data, nbytes);
out_invalidargs: out_invalidargs:
if (actual) if (actual)