Commit 5b697eb1 authored by Brandon Invergo's avatar Brandon Invergo

Make variable declaration more C99-like (old habits die hard)

parent 6b9abfd9
This diff is collapsed.
......@@ -92,9 +92,6 @@ static struct argp argp = {options, parse_opt, args_doc, doc,
(const struct argp_child *)NULL,
NULL, (const char *)NULL};
/* static lk_device_t **lk_device_list = NULL; */
/* static size_t lk_num_devices; */
void
resync_events (lk_device_t *device)
{
......@@ -128,14 +125,11 @@ void
build_init_path (char *init_path)
{
bool nonenv = false;
char *home = NULL;
char *config_home = NULL;
char *config_dir = NULL;
config_home = getenv ("XDG_CONFIG_HOME");
char *config_home = getenv ("XDG_CONFIG_HOME");
if (!config_home || strlen (config_home) == 0)
{
home = getenv ("HOME");
char *home = getenv ("HOME");
if (home)
{
config_home = (char *)malloc ((strlen (home)+9)*sizeof (char));
......@@ -153,7 +147,7 @@ build_init_path (char *init_path)
return;
}
}
config_dir = (char *)malloc ((strlen (config_home)+14)*sizeof (char));
char *config_dir = (char *)malloc ((strlen (config_home)+14)*sizeof (char));
if (!config_dir)
{
error (EXIT_FAILURE, errno, _("Memory exhausted"));
......@@ -256,8 +250,7 @@ idle_loop (void *data)
static void
run_exit_hooks (int sig)
{
size_t i;
for (i=0; i<lk_num_devices; i++)
for (size_t i=0; i<lk_num_devices; i++)
{
run_exit_hook (lk_device_list[i]->id);
}
......@@ -269,8 +262,7 @@ run_exit_hooks (int sig)
void *
launch_guile_event_loop (void *threaddata)
{
lk_device_t *device;
device = (lk_device_t *)threaddata;
lk_device_t *device = (lk_device_t *)threaddata;
scm_with_guile (event_loop, device);
pthread_exit (NULL);
}
......@@ -278,8 +270,7 @@ launch_guile_event_loop (void *threaddata)
void *
launch_guile_idle_loop (void *threaddata)
{
lk_device_t *device;
device = (lk_device_t *)threaddata;
lk_device_t *device = (lk_device_t *)threaddata;
scm_with_guile (idle_loop, device);
pthread_exit (NULL);
}
......@@ -287,25 +278,16 @@ launch_guile_idle_loop (void *threaddata)
int
main (int argc, char **argv)
{
error_t argp_result;
size_t i;
int ev_thread_rc, idle_thread_rc;
pthread_t *threads;
pthread_t *idle_threads;
pthread_attr_t attr;
char *init_path;
int err;
/* setlocale (LC_ALL, ""); */
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
init_path = (char *)malloc (512*sizeof (char));
char *init_path = (char *)malloc (512*sizeof (char));
build_init_path (init_path);
arguments.init_file = NULL;
arguments.debug = false;
argp_result = argp_parse (&argp, argc, argv, 0, 0, &arguments);
error_t argp_result = argp_parse (&argp, argc, argv, 0, 0, &arguments);
if (argp_result)
error (EXIT_FAILURE, argp_result, _("Failed to parse arguments"));
......@@ -324,30 +306,31 @@ main (int argc, char **argv)
signal (SIGTERM, run_exit_hooks);
signal (SIGINT, run_exit_hooks);
threads = (pthread_t *)malloc (lk_num_devices * sizeof (pthread_t));
pthread_t *threads = (pthread_t *)malloc (lk_num_devices * sizeof (pthread_t));
if (!threads)
{
error (EXIT_FAILURE, errno, _("Memory exhausted"));
}
idle_threads = (pthread_t *)malloc (lk_num_devices * sizeof (pthread_t));
pthread_t *idle_threads = (pthread_t *)malloc (lk_num_devices * sizeof (pthread_t));
if (!idle_threads)
{
error (EXIT_FAILURE, errno, _("Memory exhausted"));
}
pthread_attr_t attr;
pthread_attr_init (&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
for (i=0; i<lk_num_devices; i++)
for (size_t i=0; i<lk_num_devices; i++)
{
ev_thread_rc = pthread_create (&threads[i], &attr,
launch_guile_event_loop,
lk_device_list[i]);
int ev_thread_rc = pthread_create (&threads[i], &attr,
launch_guile_event_loop,
lk_device_list[i]);
if (ev_thread_rc)
{
error (EXIT_FAILURE, errno, _("Error creating thread"));
}
idle_thread_rc = pthread_create (&idle_threads[i], &attr,
launch_guile_idle_loop,
lk_device_list[i]);
int idle_thread_rc = pthread_create (&idle_threads[i], &attr,
launch_guile_idle_loop,
lk_device_list[i]);
if (idle_thread_rc)
{
error (EXIT_FAILURE, errno, _("Error creating thread"));
......@@ -356,9 +339,9 @@ main (int argc, char **argv)
pthread_attr_destroy(&attr);
for (i=0; i<lk_num_devices; i++)
for (size_t i=0; i<lk_num_devices; i++)
{
ev_thread_rc = pthread_join (threads[i], NULL);
int ev_thread_rc = pthread_join (threads[i], NULL);
switch (ev_thread_rc)
{
case EDEADLK:
......@@ -371,7 +354,7 @@ main (int argc, char **argv)
error (0, errno, _("Thread not found"));
break;
}
idle_thread_rc = pthread_join (idle_threads[i], NULL);
int idle_thread_rc = pthread_join (idle_threads[i], NULL);
switch (idle_thread_rc)
{
case EDEADLK:
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment