]> sigrok.org Git - libsigrok.git/commitdiff
Fix all warnings and re-enable -Wextra.
authorUwe Hermann <redacted>
Fri, 9 Apr 2010 20:18:46 +0000 (22:18 +0200)
committerUwe Hermann <redacted>
Fri, 9 Apr 2010 20:18:46 +0000 (22:18 +0200)
13 files changed:
datastore.c
device.c
filter.c
hardware/common/serial.c
hardware/openbench-logic-sniffer/ols.c
hardware/saleae-logic/saleae-logic.c
hardware/zeroplus-logic-cube/zeroplus.c
hwplugin.c
output/output_gnuplot.c
output/output_text.c
output/output_vcd.c
session.c
sigrok.h

index 7f6f575a290f72592dfad04bd58be73c559e1411..683a8abef1f3d7a65b99af5edc2ecb2d1cb8239f 100644 (file)
@@ -54,9 +54,14 @@ void datastore_destroy(struct datastore *ds)
 
 void datastore_put(struct datastore *ds, void *data, unsigned int length, int in_unitsize, int *probelist)
 {
-       int capacity, stored, size, num_chunks, chunk_bytes_free, chunk_offset;
+       unsigned int stored;
+       int capacity, size, num_chunks, chunk_bytes_free, chunk_offset;
        gpointer chunk;
 
+       /* QUICK HACK */
+       in_unitsize = in_unitsize;
+       probelist = probelist;
+
        if(ds->chunklist == NULL)
                chunk = new_chunk(&ds);
        else
@@ -73,7 +78,7 @@ void datastore_put(struct datastore *ds, void *data, unsigned int length, int in
                        chunk_offset = 0;
                }
 
-               if(length - stored > chunk_bytes_free)
+               if(length - stored > (unsigned int)chunk_bytes_free)
                        size = chunk_bytes_free;
                else
                        /* last part, won't fill up this chunk */
index cc6b0549a65f0eae88b522f2d6160b1730d797c7..cef3aac3dd787db6bfc4c482dfb17347f951cd13 100644 (file)
--- a/device.c
+++ b/device.c
@@ -97,7 +97,7 @@ struct device *device_new(struct device_plugin *plugin, int plugin_index)
 
 void device_clear(struct device *device)
 {
-       int probenum;
+       unsigned int probenum;
 
        /* TODO: plugin-specific clear call? */
 
@@ -110,7 +110,7 @@ void device_clear(struct device *device)
 
 void device_destroy(struct device *device)
 {
-       int probenum;
+       unsigned int probenum;
 
        /* TODO: plugin-specific destroy call, need to decrease refcount in plugin */
 
@@ -201,7 +201,7 @@ void device_probe_name(struct device *device, int probenum, char *name)
 void device_trigger_clear(struct device *device)
 {
        struct probe *p;
-       int probenum;
+       unsigned int probenum;
 
        if(device->probes)
                for(probenum = 1; probenum <= g_slist_length(device->probes); probenum++)
index f9c9a09c78e9d8c056741e4a5fa49bbbdad27077..40a47ca3ff7d28e6684c066146ea8c4f34cd6172 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -29,7 +29,8 @@
 int filter_probes(int in_unitsize, int out_unitsize, int *probelist,
                char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out)
 {
-       int num_enabled_probes, in_offset, out_offset, out_bit, i;
+       unsigned int in_offset, out_offset;
+       int num_enabled_probes, out_bit, i;
        uint64_t sample_in, sample_out;
 
        *data_out = malloc(length_in);
index 67a4ab73a2b259d4d8c268fc32f51156b7051886..dfc6d5578c87b03c998a4b688dd50f99e0025da6 100644 (file)
@@ -48,7 +48,7 @@ GSList *list_serial_ports(void)
 {
        glob_t g;
        GSList *ports;
-       int i, j;
+       unsigned int i, j;
 
        ports = NULL;
        for(i = 0; serial_port_glob[i]; i++)
index d4372418610fa4f0d881969d1c1f6d5e817accef..601ab82f6d044f63abaa14339cf0e779a2837892 100644 (file)
@@ -448,7 +448,7 @@ static int hw_set_configuration(int device_index, int capability, void *value)
 
 static int receive_data(int fd, int revents, void *user_data)
 {
-       static int num_transfers = 0;
+       static unsigned int num_transfers = 0;
        static int num_bytes = 0;
        static char last_sample[4] = {0xff};
        static unsigned char sample[4] = {0}, tmp_sample[4];
@@ -672,6 +672,9 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
 {
        struct datafeed_packet packet;
 
+       /* QUICK HACK */
+       device_index = device_index;
+
        packet.type = DF_END;
        packet.length = 0;
        session_bus(session_device_id, &packet);
index 768d0f74a1fd4593113ab681d43f282dd9e9a0fa..95598192ab50a597ad8f949239a478273b70a5a1 100644 (file)
@@ -66,7 +66,7 @@ static GSList *device_instances = NULL;
  * upgrade -- this is like a global lock. No device will open until a proper
  * delay after the last device was upgraded.
  */
-GTimeVal firmware_updated = { 0 };
+GTimeVal firmware_updated = { 0, 0 };
 
 static libusb_context *usb_context = NULL;
 
@@ -197,8 +197,8 @@ static int opendev2(int device_index, struct sigrok_device_instance **sdi,
        return 0;
 }
 
-static int opendev3(int device_index, struct sigrok_device_instance **sdi,
-                   libusb_device *dev, struct libusb_device_descriptor *des)
+static int opendev3(struct sigrok_device_instance **sdi, libusb_device *dev,
+                   struct libusb_device_descriptor *des)
 {
        int err;
 
@@ -259,7 +259,7 @@ struct sigrok_device_instance *sl_open_device(int device_index)
                libusb_get_device_list(usb_context, &devlist);
                for (i = 0; devlist[i]; i++) {
                        /* TODO: Error handling. */
-                       err = opendev3(device_index, &sdi, devlist[i], &des);
+                       err = opendev3(&sdi, devlist[i], &des);
                }
        } else {
                /* Status must be ST_ACTIVE, i.e. already in use... */
@@ -356,6 +356,9 @@ static int hw_init(char *deviceinfo)
        libusb_device **devlist;
        int err, devcnt, i;
 
+       /* QUICK HACK */
+       deviceinfo = deviceinfo;
+
        if (libusb_init(&usb_context) != 0) {
                g_warning("Failed to initialize USB.");
                return 0;
@@ -581,13 +584,18 @@ static int receive_data(int fd, int revents, void *user_data)
 {
        struct timeval tv;
 
+       /* QUICK HACK */
+       fd = fd;
+       revents = revents;
+       user_data = user_data;
+
        tv.tv_sec = tv.tv_usec = 0;
        libusb_handle_events_timeout(usb_context, &tv);
 
        return TRUE;
 }
 
-static void trigger_helper(int i, unsigned char *cur_buf, int cur_buflen,
+static void trigger_helper(int i, unsigned char *cur_buf,
                           struct datafeed_packet *packet, void *user_data,
                           int *trigger_offset)
 {
@@ -698,8 +706,8 @@ void receive_transfer(struct libusb_transfer *transfer)
        trigger_offset = 0;
        if (trigger_stage >= 0) {
                for (i = 0; i < cur_buflen; i++) {
-                       trigger_helper(i, cur_buf, cur_buflen, &packet,
-                                      user_data, &trigger_offset);
+                       trigger_helper(i, cur_buf, &packet, user_data,
+                                      &trigger_offset);
                }
        }
 
@@ -712,7 +720,7 @@ void receive_transfer(struct libusb_transfer *transfer)
                g_free(cur_buf);
 
                num_samples += cur_buflen;
-               if (num_samples > limit_samples) {
+               if ((unsigned int)num_samples > limit_samples) {
                        /* End the acquisition. */
                        packet.type = DF_END;
                        session_bus(user_data, &packet);
@@ -787,6 +795,9 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
 {
        struct datafeed_packet packet;
 
+       /* QUICK HACK */
+       device_index = device_index;
+
        packet.type = DF_END;
        session_bus(session_device_id, &packet);
 
index e1f5540583411955d15f91a778b2c0d4850c1791..4a1e46fcf7cf0f7dfe6e13661cec0cf85af00f72 100644 (file)
@@ -137,7 +137,8 @@ struct sigrok_device_instance *zp_open_device(int device_index)
        struct sigrok_device_instance *sdi;
        libusb_device **devlist;
        struct libusb_device_descriptor des;
-       int err, i, j;
+       unsigned int j;
+       int err, i;
 
        if(!(sdi = get_sigrok_device_instance(device_instances, device_index)))
                return NULL;
@@ -263,6 +264,9 @@ static int hw_init(char *deviceinfo)
        libusb_device **devlist;
        int err, devcnt, i;
 
+       /* QUICK HACK */
+       deviceinfo = deviceinfo;
+
        if(libusb_init(&usb_context) != 0) {
                g_warning("Failed to initialize USB.");
                return 0;
@@ -416,12 +420,11 @@ static int hw_get_status(int device_index)
 
 static int *hw_get_capabilities(void)
 {
-
        return capabilities;
 }
 
 // XXX this will set the same samplerate for all devices
-int set_configuration_samplerate(struct sigrok_device_instance *sdi, uint64_t samplerate)
+static int set_configuration_samplerate(uint64_t samplerate)
 {
        g_message("%s(%llu)", __FUNCTION__, samplerate);
        if (samplerate > MHZ(1))
@@ -447,7 +450,7 @@ static int hw_set_configuration(int device_index, int capability, void *value)
        switch (capability) {
                case HWCAP_SAMPLERATE:
                        tmp_u64 = value;
-                       return set_configuration_samplerate(sdi, *tmp_u64);
+                       return set_configuration_samplerate(*tmp_u64);
 
                case HWCAP_PROBECONFIG:
                        return configure_probes( (GSList *) value);
@@ -467,7 +470,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
        struct datafeed_packet packet;
        struct datafeed_header header;
        int res;
-       int packet_num;
+       unsigned int packet_num;
        unsigned char *buf;
 
        if( !(sdi = get_sigrok_device_instance(device_instances, device_index)))
index 6c0f06b31fefca62ac3b995d8df767de1b9df1b3..3f0e49652fec14681b18a20a8e9d29b23e3acd4f 100644 (file)
@@ -137,6 +137,8 @@ struct usb_device_instance *usb_device_instance_new(uint8_t bus, uint8_t address
 
 void usb_device_instance_free(struct usb_device_instance *usb)
 {
+       /* QUICK HACK */
+       usb = usb;
 
        /* nothing to do for this device instance type */
 
index e79bd9f566de00e285b3cb185dff5939e99bfc68..9d550a48ef4a14db76940aeb2f2443475943ce3e 100644 (file)
@@ -25,8 +25,8 @@
 #include "config.h"
 
 struct context {
-       int num_enabled_probes;
-       int unitsize;
+       unsigned int num_enabled_probes;
+       unsigned int unitsize;
        char *probelist[65];
        char *header;
 };
@@ -48,7 +48,8 @@ static int init(struct output *o)
        struct probe *probe;
        GSList *l;
        uint64_t samplerate;
-       int i, b, num_probes;
+       unsigned int i;
+       int b, num_probes;
        char *c, *samplerate_s;
        char wbuf[1000];
 
@@ -128,7 +129,7 @@ static int data(struct output *o, char *data_in, uint64_t length_in,
                char **data_out, uint64_t *length_out)
 {
        struct context *ctx;
-       int offset, outsize, p, curbit;
+       unsigned int offset, outsize, p, curbit;
        uint64_t sample, count = 0;
        char *outbuf, *c;
 
index c4b9c95daa9c886e1bd36d449868489e61d8c08d..bd2dfcd63cb3d8e9fce01140275abebf08fbb188 100644 (file)
@@ -27,9 +27,9 @@
 #define DEFAULT_BPL_HEX 256
 
 struct context {
-       int num_enabled_probes;
+       unsigned int num_enabled_probes;
        int samples_per_line;
-       int unitsize;
+       unsigned int unitsize;
        int line_offset;
        int linebuf_len;
        char *probelist[65];
@@ -40,7 +40,7 @@ struct context {
 };
 
 
-static void flush_linebufs(struct context *ctx, GSList *probes, char *outbuf)
+static void flush_linebufs(struct context *ctx, char *outbuf)
 {
        static int max_probename_len = 0;
        int len, i;
@@ -123,7 +123,7 @@ static int event(struct output *o, int event_type, char **data_out, uint64_t *le
        case DF_END:
                outsize = ctx->num_enabled_probes * (ctx->samples_per_line + 20) + 512;
                outbuf = calloc(1, outsize);
-               flush_linebufs(ctx, o->device->probes, outbuf);
+               flush_linebufs(ctx, outbuf);
                *data_out = outbuf;
                *length_out = strlen(outbuf);
                free(o->internal);
@@ -146,7 +146,7 @@ static int init_binary(struct output *o)
 static int data_binary(struct output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out)
 {
        struct context *ctx;
-       int outsize, offset, p;
+       unsigned int outsize, offset, p;
        uint64_t sample;
        char *outbuf;
 
@@ -183,7 +183,7 @@ static int data_binary(struct output *o, char *data_in, uint64_t length_in, char
 
                        /* end of line */
                        if(ctx->spl_cnt >= ctx->samples_per_line) {
-                               flush_linebufs(ctx, o->device->probes, outbuf);
+                               flush_linebufs(ctx, outbuf);
                                ctx->line_offset = ctx->spl_cnt = 0;
                        }
                }
@@ -208,7 +208,7 @@ static int init_hex(struct output *o)
 static int data_hex(struct output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out)
 {
        struct context *ctx;
-       int outsize, offset, p;
+       unsigned int outsize, offset, p;
        uint64_t sample;
        char *outbuf;
 
@@ -244,7 +244,7 @@ static int data_hex(struct output *o, char *data_in, uint64_t length_in, char **
 
                /* end of line */
                if(ctx->spl_cnt >= ctx->samples_per_line) {
-                       flush_linebufs(ctx, o->device->probes, outbuf);
+                       flush_linebufs(ctx, outbuf);
                        ctx->line_offset = ctx->spl_cnt = 0;
                }
        }
index 767e398dc5bfec7abe078b187417cebe99173108..4a46e854a881b9cdffad1257ad61c8dcc422bb8e 100644 (file)
@@ -137,7 +137,8 @@ static int data(struct output *o, char *data_in, uint64_t length_in,
                char **data_out, uint64_t *length_out)
 {
        struct context *ctx;
-       int offset, outsize, p, curbit, prevbit;
+       unsigned int offset, outsize;
+       int p, curbit, prevbit;
        uint64_t sample, prevsample;
        char *outbuf, *c;
 
index 2d6a74f98b784bff9e07cfe1f7aa6340fee47971..0dc5142455b42a64e7a451cdc270b29d9c652214 100644 (file)
--- a/session.c
+++ b/session.c
 struct session *session;
 
 
-struct session *session_load(char *filename)
+struct session *session_load(const char *filename)
 {
        struct session *session;
 
        /* TODO: implement */
        session = NULL;
 
+       /* QUICK HACK */
+       filename = filename;
+
        return session;
 }
 
index 4c3af637779d5fbfd5089631d712c63593449ea9..1eedd8bca75b5b81c276cf8cb342afe8e414f973 100644 (file)
--- a/sigrok.h
+++ b/sigrok.h
@@ -369,7 +369,7 @@ struct session {
 };
 
 /* Session setup */
-struct session *session_load(char *filename);
+struct session *session_load(const char *filename);
 struct session *session_new(void);
 void session_destroy(void);
 void session_device_clear(void);