Fix up a large pile of warnings.

This commit is contained in:
Solomon Peachy 2013-08-21 22:17:25 -04:00
parent 8372f92545
commit 65e5e28b59
4 changed files with 133 additions and 144 deletions

View File

@ -1,7 +1,7 @@
# linuxaldl Makefile
CC = gcc
CFLAGS = -g -Wextra -Wall -Wno-unused `pkg-config --cflags gtk+-2.0`
CFLAGS = -g -Wextra -Wall -Wno-unused-parameter `pkg-config --cflags gtk+-2.0`
V = @

View File

@ -39,6 +39,135 @@ extern linuxaldl_settings aldl_settings;
// global variable which holds gui-specific pointers, data, etc
linuxaldl_gui_settings aldl_gui_settings = { NULL, {0,0}, ALDL_LOG_RAW, NULL, 0};
// ===================================
// EXIT / DELETE_EVENT
// ===================================
static gboolean linuxaldl_gui_quit( GtkWidget *widget, GdkEvent *event, gpointer data);
// called on delete_event, closes the connection (if there is one)
// and call gtk_main_quit(). if a transfer is currently in progress,
// should pop up a dialogue to confirm quitting.
static gboolean hide_on_delete( GtkWidget *widget, GdkEvent *event, gpointer data);
// hides the window then returns TRUE so that a window is not destroyed on a delete event
// ===================================
// SCAN OPERATION FOR GUI MODE
// ===================================
static void linuxaldl_gui_scan_interval_changed( GtkAdjustment *adj, gpointer data);
// callback for change in the adjustment for the aldl_settings.scan_interval field.
// if scanning is not taking place, does nothing except store the new values and enforce
// timeout/ scan interval constraints (interval must be at least 20msec more than timeout).
// otherwise it reassigns the scan interval to the new value immediately.
// adj must point to the GtkAdjustment for the scan interval.
static gint linuxaldl_gui_scan_on_interval(gpointer data);
// callback for gtk_timeout interval timer. if aldl_settings.scanning == 1
// then this function will call linuxaldl_gui_scan
static void linuxaldl_gui_scan_toggle( GtkWidget *widget, gpointer data);
// starts/stops scanning. output is written to the log file if one was specified
// otherwise it is written to stdout.
static void linuxaldl_gui_scan(GtkWidget *widget, gpointer data);
// performs a single scan operation (one mode1 message, updates/logs data)
static void linuxaldl_gui_datareadout_show(GtkWidget* widget, gpointer data);
// shows the data display window, setting it up for the current definition.
// data must point to the data display window object generated by
// the linuxaldl_gui_datareadout_new function.
// this function builds the data display window,
// and allocates aldl_settings.data_readout_labels
static void linuxaldl_gui_datareadout_update(GtkWidget* widget, gpointer data);
// updates the data display window, refreshing it with the current data values.
// this function will check if aldl_settings.data_readout_labels
// has been allocated yet before it tries to update the values.
// if it has not yet been allocated, it returns doing nothing.
// .csv log file updating is also done here.
// ===================================
// LOAD .LOG FILE SELECTION
// ===================================
static void linuxaldl_gui_load( GtkWidget *widget, GtkFileSelection *fs);
// load a log file to view/playback. XXX NOT YET IMPLEMENTED.
// ===================================
// SAVE .LOG FILE SELECTION
// ===================================
static void linuxaldl_gui_save( GtkWidget *widget, GtkFileSelection *fs);
// selects a log file to save to.
// =======================
// CSV FORMAT LOGGING
// =======================
static void linuxaldl_gui_write_csv_header();
// write the header line to the csv file
static void linuxaldl_gui_write_csv_line();
// write a data line for the csv file
static void linuxaldl_gui_widgetshow(GtkWidget *widget, gpointer data);
// calls gtk_widget_show on the widget specified in the data argument
static void linuxaldl_gui_widgethide(GtkWidget *widget, gpointer data);
// calls gtk_widget_hide on the widget specified in the data argument
static void linuxaldl_gui_try_choosedef( GtkWidget *widget, gpointer data);
// opens the definition selection dialog if no definition has been selected,
// otherwise pops up an alert and returns
static void linuxaldl_gui_load_definition( GtkWidget *widget, gpointer data);
// refreshes the definition in aldl_settings based on the definition name chosen in
// the choose definition gui dialogue
// ==========================================================================
//
// GUI accessory windows
//
// ==========================================================================
// ==================================
// Options & Settings window
// ==================================
static GtkWidget* linuxaldl_gui_options_new();
// returns a GtkWidget pointer to a new options window
// ==================================
// Data Display window
// ==================================
static GtkWidget* linuxaldl_gui_datareadout_new();
// returns a GtkWidget pointer to the datareadout window
// ==================================
// Definition selection dialog
// ==================================
static GtkWidget* linuxaldl_gui_choosedef_new();
// returns a GtkWidget pointer to the definition selection dialog
// for the definition table in the global "aldl_settings" struct
// ========================================================================
//
// GUI MODE FUNCTION DEFINITIONS
@ -65,7 +194,6 @@ int linuxaldl_gui(int argc, char* argv[])
GtkWidget *optionsw; // options/settings window
GtkWidget *choosedefw; // definition selection dialogue
GtkWidget *datareadoutw; // datareadout window
char* logfilename;
gtk_init(&argc, &argv);
@ -428,8 +556,6 @@ static void linuxaldl_gui_scan( GtkWidget *widget, gpointer data)
// this function is called when the scan button is toggled
static void linuxaldl_gui_scan_toggle( GtkWidget *widget, gpointer data)
{
struct itimerval timer_value;
// if the button is down
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
{
@ -479,7 +605,7 @@ static void linuxaldl_gui_load( GtkWidget *widget, GtkFileSelection *fs){
// selected in the save log file selection dialogue. it saves
// the current buffer into the selected file.
static void linuxaldl_gui_save( GtkWidget *widget, GtkFileSelection *fs){
int i, length, res;
int length;
char extension[4];
const char* logfilename = gtk_file_selection_get_filename(fs);
aldl_settings.logfilename= logfilename;
@ -691,7 +817,6 @@ GtkWidget* linuxaldl_gui_options_new()
// returns a GtkWidget pointer to an empty datareadout window
GtkWidget* linuxaldl_gui_datareadout_new()
{
int i = 0;
GtkWidget* dataw;
dataw = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@ -718,9 +843,6 @@ static void linuxaldl_gui_datareadout_update(GtkWidget* widget, gpointer data)
unsigned int i=0;
byte_def_t* defs = aldl_settings.definition->mode1_def;
byte_def_t* cur_def;
float converted_val;
char new_label_string[10];
for (i=0; defs[i].label != NULL; i++) // while not at the last defined byte
{
@ -788,7 +910,6 @@ static void linuxaldl_gui_datareadout_show(GtkWidget* widget, gpointer data)
// data_readout_labels[i] is not defined.
// XXX need to free all the strings on exit, as well as this array..
aldl_gui_settings.data_readout_labels = g_malloc0((num_items)*sizeof(GtkWidget*));
GtkWidget *cur_vbox;
GtkWidget *cur_frame;
GtkWidget *cur_label;
GtkWidget *cur_table;

View File

@ -57,137 +57,6 @@ typedef struct _linuxaldl_gui_settings
int linuxaldl_gui(int argc, char* argv[]);
// runs the linuxaldl GTK+ graphical user interface
// ===================================
// EXIT / DELETE_EVENT
// ===================================
static gboolean linuxaldl_gui_quit( GtkWidget *widget, GdkEvent *event, gpointer data);
// called on delete_event, closes the connection (if there is one)
// and call gtk_main_quit(). if a transfer is currently in progress,
// should pop up a dialogue to confirm quitting.
static gboolean hide_on_delete( GtkWidget *widget, GdkEvent *event, gpointer data);
// hides the window then returns TRUE so that a window is not destroyed on a delete event
// ===================================
// SCAN OPERATION FOR GUI MODE
// ===================================
static void linuxaldl_gui_scan_interval_changed( GtkAdjustment *adj, gpointer data);
// callback for change in the adjustment for the aldl_settings.scan_interval field.
// if scanning is not taking place, does nothing except store the new values and enforce
// timeout/ scan interval constraints (interval must be at least 20msec more than timeout).
// otherwise it reassigns the scan interval to the new value immediately.
// adj must point to the GtkAdjustment for the scan interval.
gint linuxaldl_gui_scan_on_interval(gpointer data);
// callback for gtk_timeout interval timer. if aldl_settings.scanning == 1
// then this function will call linuxaldl_gui_scan
static void linuxaldl_gui_scan_toggle( GtkWidget *widget, gpointer data);
// starts/stops scanning. output is written to the log file if one was specified
// otherwise it is written to stdout.
static void linuxaldl_gui_scan(GtkWidget *widget, gpointer data);
// performs a single scan operation (one mode1 message, updates/logs data)
static void linuxaldl_gui_stop( GtkWidget *widget, gpointer data);
// stops scanning. this causes aldl_scan_and_log to return.
// ==========================================================================
//
// GUI accessory windows
//
// ==========================================================================
// ==================================
// Options & Settings window
// ==================================
GtkWidget* linuxaldl_gui_options_new();
// returns a GtkWidget pointer to a new options window
// ==================================
// Data Display window
// ==================================
GtkWidget* linuxaldl_gui_datareadout_new();
// returns a GtkWidget pointer to the datareadout window
static void linuxaldl_gui_datareadout_show(GtkWidget* widget, gpointer data);
// shows the data display window, setting it up for the current definition.
// data must point to the data display window object generated by
// the linuxaldl_gui_datareadout_new function.
// this function builds the data display window,
// and allocates aldl_settings.data_readout_labels
static void linuxaldl_gui_datareadout_update(GtkWidget* widget, gpointer data);
// updates the data display window, refreshing it with the current data values.
// this function will check if aldl_settings.data_readout_labels
// has been allocated yet before it tries to update the values.
// if it has not yet been allocated, it returns doing nothing.
// .csv log file updating is also done here.
// ===================================
// LOAD .LOG FILE SELECTION
// ===================================
static void linuxaldl_gui_load( GtkWidget *widget, GtkFileSelection *fs);
// load a log file to view/playback. XXX NOT YET IMPLEMENTED.
// ===================================
// SAVE .LOG FILE SELECTION
// ===================================
static void linuxaldl_gui_save( GtkWidget *widget, GtkFileSelection *fs);
// selects a log file to save to.
// =======================
// CSV FORMAT LOGGING
// =======================
static void linuxaldl_gui_write_csv_header();
// write the header line to the csv file
static void linuxaldl_gui_write_csv_line();
// write a data line for the csv file
static void linuxaldl_gui_widgetshow(GtkWidget *widget, gpointer data);
// calls gtk_widget_show on the widget specified in the data argument
static void linuxaldl_gui_widgethide(GtkWidget *widget, gpointer data);
// calls gtk_widget_hide on the widget specified in the data argument
// ==================================
// Definition selection dialog
// ==================================
static void linuxaldl_gui_try_choosedef( GtkWidget *widget, gpointer data);
// opens the definition selection dialog if no definition has been selected,
// otherwise pops up an alert and returns
GtkWidget* linuxaldl_gui_choosedef_new();
// returns a GtkWidget pointer to the definition selection dialog
// for the definition table in the global "aldl_settings" struct
static void linuxaldl_gui_load_definition( GtkWidget *widget, gpointer data);
// refreshes the definition in aldl_settings based on the definition name chosen in
// the choose definition gui dialogue
// ==================================
// Alert Window Popup
// ==================================

View File

@ -201,8 +201,8 @@ typedef void (*sighandler_t)(int);
// restored to its original state.
int read_sequence(int fd, void *buf, size_t count, char *seq, size_t seq_size, long secs, long usecs)
{
unsigned int seq_matched = 0, bytes_read = 0, i;
int res, retval = 0;
unsigned int seq_matched = 0, bytes_read = 0;
int i, res, retval = 0;
size_t seqbuf_size = count;
char* seqbuf = malloc(seqbuf_size);
@ -254,7 +254,6 @@ int read_sequence(int fd, void *buf, size_t count, char *seq, size_t seq_size, l
}
else // if the sequence hasn't been matched...
{
res = read(fd, seqbuf, seqbuf_size);
if (res==0)
continue;