Make more variables/functions static and non-global.
The 'GSList *devices' from device.c was actually really global (i.e., listed in sigrok.h), which is now fixed.
This commit is contained in:
parent
c5d660ae24
commit
a0ecd83bc6
2
device.c
2
device.c
|
@ -22,7 +22,7 @@
|
|||
#include <sigrok.h>
|
||||
#include <sigrok-internal.h>
|
||||
|
||||
GSList *devices = NULL;
|
||||
static GSList *devices = NULL;
|
||||
|
||||
/**
|
||||
* Scan the system for attached logic analyzers / devices.
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include <string.h>
|
||||
#include "config.h"
|
||||
|
||||
|
||||
int ezusb_reset(struct libusb_device_handle *hdl, int set_clear)
|
||||
{
|
||||
int err;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
// FIXME: Must be moved, or rather passed as function argument.
|
||||
#ifdef _WIN32
|
||||
HANDLE hdl;
|
||||
static HANDLE hdl;
|
||||
#endif
|
||||
|
||||
const char *serial_port_glob[] = {
|
||||
|
|
|
@ -564,7 +564,7 @@ static int receive_data(int fd, int revents, void *user_data)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void receive_transfer(struct libusb_transfer *transfer)
|
||||
static void receive_transfer(struct libusb_transfer *transfer)
|
||||
{
|
||||
/* TODO: these statics have to move to fx2_device struct */
|
||||
static int num_samples = 0;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <sigrok-internal.h>
|
||||
|
||||
/* The list of loaded plugins lives here. */
|
||||
GSList *plugins;
|
||||
static GSList *plugins;
|
||||
|
||||
/*
|
||||
* This enumerates which plugin capabilities correspond to user-settable
|
||||
|
@ -68,7 +68,6 @@ extern struct sr_device_plugin link_mso19_plugin_info;
|
|||
extern struct sr_device_plugin alsa_plugin_info;
|
||||
#endif
|
||||
|
||||
|
||||
/* TODO: No linked list needed, this can be a simple array. */
|
||||
int load_hwplugins(void)
|
||||
{
|
||||
|
@ -99,7 +98,6 @@ int load_hwplugins(void)
|
|||
plugins = g_slist_append(plugins, (gpointer *)&alsa_plugin_info);
|
||||
#endif
|
||||
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
|
@ -133,7 +131,6 @@ void sr_cleanup_hwplugins(void)
|
|||
if (plugin->cleanup)
|
||||
plugin->cleanup();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct sr_device_instance *sr_device_instance_new(int index, int status,
|
||||
|
@ -195,7 +192,6 @@ void sr_device_instance_free(struct sr_device_instance *sdi)
|
|||
g_free(sdi->model);
|
||||
g_free(sdi->version);
|
||||
g_free(sdi);
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBUSB_1_0
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#define CHUNKSIZE 4096
|
||||
#define DEFAULT_NUM_PROBES 8
|
||||
|
||||
|
||||
static int format_match(const char *filename)
|
||||
{
|
||||
/* suppress compiler warning */
|
||||
|
|
17
session.c
17
session.c
|
@ -38,12 +38,12 @@ struct source {
|
|||
};
|
||||
|
||||
/* There can only be one session at a time. */
|
||||
/* 'session' is not static, it's used elsewhere (via 'extern'). */
|
||||
struct sr_session *session;
|
||||
int num_sources = 0;
|
||||
|
||||
struct source *sources = NULL;
|
||||
int source_timeout = -1;
|
||||
static int num_sources = 0;
|
||||
|
||||
static struct source *sources = NULL;
|
||||
static int source_timeout = -1;
|
||||
|
||||
struct sr_session *sr_session_new(void)
|
||||
{
|
||||
|
@ -54,7 +54,6 @@ struct sr_session *sr_session_new(void)
|
|||
|
||||
void sr_session_destroy(void)
|
||||
{
|
||||
|
||||
g_slist_free(session->devices);
|
||||
|
||||
/* TODO: Loop over protocol decoders and free them. */
|
||||
|
@ -152,7 +151,6 @@ static void sr_session_run_poll()
|
|||
}
|
||||
}
|
||||
free(fds);
|
||||
|
||||
}
|
||||
|
||||
int sr_session_start(void)
|
||||
|
@ -174,7 +172,6 @@ int sr_session_start(void)
|
|||
|
||||
void sr_session_run(void)
|
||||
{
|
||||
|
||||
sr_info("session: running");
|
||||
session->running = TRUE;
|
||||
|
||||
|
@ -186,15 +183,12 @@ void sr_session_run(void)
|
|||
else
|
||||
/* real sources, use g_poll() main loop */
|
||||
sr_session_run_poll();
|
||||
|
||||
}
|
||||
|
||||
void sr_session_halt(void)
|
||||
{
|
||||
|
||||
sr_info("session: halting");
|
||||
session->running = FALSE;
|
||||
|
||||
}
|
||||
|
||||
void sr_session_stop(void)
|
||||
|
@ -209,7 +203,6 @@ void sr_session_stop(void)
|
|||
if (device->plugin && device->plugin->stop_acquisition)
|
||||
device->plugin->stop_acquisition(device->plugin_index, device);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void datafeed_dump(struct sr_datafeed_packet *packet)
|
||||
|
@ -236,7 +229,6 @@ static void datafeed_dump(struct sr_datafeed_packet *packet)
|
|||
default:
|
||||
sr_dbg("bus: received unknown packet type %d", packet->type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void sr_session_bus(struct sr_device *device, struct sr_datafeed_packet *packet)
|
||||
|
@ -304,4 +296,3 @@ void sr_session_source_remove(int fd)
|
|||
free(new_sources);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ static int capabilities[] = {
|
|||
0,
|
||||
};
|
||||
|
||||
|
||||
static struct session_vdevice *get_vdevice_by_index(int device_index)
|
||||
{
|
||||
struct sr_device_instance *sdi;
|
||||
|
@ -147,7 +146,6 @@ static void hw_cleanup(void)
|
|||
sr_session_source_remove(-1);
|
||||
|
||||
g_free(sessionfile);
|
||||
|
||||
}
|
||||
|
||||
static int hw_opendev(int device_index)
|
||||
|
@ -190,7 +188,7 @@ static int hw_get_status(int device_index)
|
|||
/* Avoid compiler warnings. */
|
||||
(void)device_index;
|
||||
|
||||
if (devices)
|
||||
if (sr_device_list() != NULL)
|
||||
return SR_OK;
|
||||
else
|
||||
return SR_ERR;
|
||||
|
@ -198,7 +196,6 @@ static int hw_get_status(int device_index)
|
|||
|
||||
static int *hw_get_capabilities(void)
|
||||
{
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
|
@ -296,6 +293,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
/* Not static, it's used elsewhere (via 'extern'). */
|
||||
struct sr_device_plugin session_driver = {
|
||||
"session",
|
||||
"Session-emulating driver",
|
||||
|
|
|
@ -225,9 +225,6 @@ struct sr_probe {
|
|||
char *trigger;
|
||||
};
|
||||
|
||||
/* TODO: Get rid of this global variable. */
|
||||
extern GSList *devices;
|
||||
|
||||
/* Hardware plugin capabilities */
|
||||
enum {
|
||||
SR_HWCAP_DUMMY, /* Used to terminate lists */
|
||||
|
|
Loading…
Reference in New Issue