Commit 8e22084f authored by Jeremy White's avatar Jeremy White Committed by Frediano Ziglio

Apply style to the main source tree.

Acked-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
parent 54e08ccc
......@@ -45,6 +45,8 @@ indent \
--space-after-casts \
--space-after-if \
--cuddle-else \
-cd0 \
-c0 \
-T agent_t \
-T SpiceCharDeviceInstance \
-T SpiceChannelEventInfo \
......@@ -83,4 +85,7 @@ indent \
-T test_t \
-T Bool \
-T shm_segment_t \
-T GtkWidget \
-T ssl_options_t \
-T GAsyncQueue \
"$@"
......@@ -42,15 +42,15 @@ static void uinput_handle_key(agent_t *agent, struct input_event *ev)
int button = 0;
switch (ev->code) {
case BTN_LEFT:
button = 1 << 0;
break;
case BTN_MIDDLE:
button = 1 << 2;
break;
case BTN_RIGHT:
button = 1 << 1;
break;
case BTN_LEFT:
button = 1 << 0;
break;
case BTN_MIDDLE:
button = 1 << 2;
break;
case BTN_RIGHT:
button = 1 << 1;
break;
}
if (ev->value > 0)
......@@ -78,16 +78,16 @@ static void uinput_handle_relative(agent_t *agent, struct input_event *ev)
static void uinput_handle_absolute(agent_t *agent, struct input_event *ev)
{
switch (ev->code) {
case ABS_X:
agent->uinput_x = ev->value;
break;
case ABS_Y:
agent->uinput_y = ev->value;
break;
default:
g_debug("%s: unknown axis %d, ignoring\n", __func__, ev->code);
return;
break;
case ABS_X:
agent->uinput_x = ev->value;
break;
case ABS_Y:
agent->uinput_y = ev->value;
break;
default:
g_debug("%s: unknown axis %d, ignoring\n", __func__, ev->code);
return;
break;
}
session_handle_mouse_position(agent->spice->session, agent->uinput_x, agent->uinput_y,
agent->uinput_buttons_state);
......@@ -117,17 +117,17 @@ static void uinput_read_cb(int fd G_GNUC_UNUSED, int event G_GNUC_UNUSED, void *
memmove(agent->uinput_buffer, agent->uinput_buffer + sizeof(*ev), agent->uinput_offset);
switch (ev->type) {
case EV_KEY:
uinput_handle_key(agent, ev);
break;
case EV_KEY:
uinput_handle_key(agent, ev);
break;
case EV_REL:
uinput_handle_relative(agent, ev);
break;
case EV_REL:
uinput_handle_relative(agent, ev);
break;
case EV_ABS:
uinput_handle_absolute(agent, ev);
break;
case EV_ABS:
uinput_handle_absolute(agent, ev);
break;
}
}
......
......@@ -91,7 +91,7 @@ static void handle_cursor_notify(display_t *display,
ir = xcb_xfixes_get_cursor_image_reply(display->c, icookie, &error);
if (error) {
g_warning("Could not get cursor_image_reply; type %d; code %d; major %d; minor %d\n",
error->response_type, error->error_code, error->major_code, error->minor_code);
error->response_type, error->error_code, error->major_code, error->minor_code);
return;
}
......@@ -149,8 +149,7 @@ static void handle_damage_notify(display_t *display, xcb_damage_notify_event_t *
scanner_push(&display->session->scanner, DAMAGE_SCAN_REPORT,
p[i].x1, p[i].y1, p[i].x2 - p[i].x1, p[i].y2 - p[i].y1);
} else {
scanner_push(&display->session->scanner, PERIODIC_SCAN_REQUEST,
0, 0, 0, 0);
scanner_push(&display->session->scanner, PERIODIC_SCAN_REQUEST, 0, 0, 0, 0);
}
pixman_region_clear(damage_region);
......@@ -523,7 +522,7 @@ shm_image_t *create_shm_image(display_t *d, unsigned int w, unsigned int h)
error = xcb_request_check(d->c, cookie);
if (error) {
g_warning("Could not attach; type %d; code %d; major %d; minor %d\n",
error->response_type, error->error_code, error->major_code, error->minor_code);
error->response_type, error->error_code, error->major_code, error->minor_code);
return NULL;
}
......@@ -573,7 +572,6 @@ int display_find_changed_tiles(display_t *d, int row, int *tiles, int tiles_acro
}
}
}
#if defined(DEBUG_SCANLINES)
fprintf(stderr, "%d: ", row);
for (i = 0; i < tiles_across; i++)
......
......@@ -32,7 +32,7 @@ struct session_struct;
** Structure definitions
**--------------------------------------------------------------------------*/
typedef struct {
int shmid; /* if shmid is -1: the shm_segment_t is "empty", other members are undefined */
int shmid; /* if shmid is -1: the shm_segment_t is "empty", other members are undefined */
size_t size;
xcb_shm_seg_t shmseg;
void *shmaddr;
......
......@@ -56,7 +56,7 @@ void gui_remote_disconnected(gui_t *gui)
void gui_disconnect_clicked(GtkWidget *widget G_GNUC_UNUSED, gpointer data)
{
gui_t *gui = (gui_t *)data;
gui_t *gui = (gui_t *) data;
session_disconnect_client(gui->session);
}
......@@ -127,14 +127,12 @@ void gui_report_error(gui_t *gui, const char *message)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW(gui->window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
message);
dialog = gtk_message_dialog_new(GTK_WINDOW(gui->window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, message);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
#if defined(GUI_MAIN)
......
......@@ -157,10 +157,10 @@ static int try_port(const char *addr, int port)
close(sock);
/*
** Oddly, you seem to get situations where the ipv6 bind will fail,
** with address in use; you can then try again and bind to the ipv4,
** but you then go on to get other failures.
*/
** Oddly, you seem to get situations where the ipv6 bind will fail,
** with address in use; you can then try again and bind to the ipv4,
** but you then go on to get other failures.
*/
break;
}
......
......@@ -83,7 +83,8 @@ void options_free(options_t *options)
}
static void string_option(gchar **dest, GKeyFile *u, GKeyFile *s, const gchar *section, const gchar *key)
static void string_option(gchar **dest, GKeyFile *u, GKeyFile *s, const gchar *section,
const gchar *key)
{
gchar *ret = NULL;
GError *error = NULL;
......@@ -171,29 +172,29 @@ static int options_handle_ssl(options_t *options, const char *spec)
if (strlen(p) == 0)
continue;
switch(i) {
case 0:
str_replace(&options->ssl.ca_cert_file, p);
break;
case 1:
str_replace(&options->ssl.certs_file, p);
break;
case 2:
str_replace(&options->ssl.private_key_file, p);
break;
case 3:
str_replace(&options->ssl.key_password, p);
break;
case 4:
str_replace(&options->ssl.dh_key_file, p);
break;
case 5:
str_replace(&options->ssl.ciphersuite, p);
break;
default:
fprintf(stderr, "Error: invalid ssl specification.");
rc = X11SPICE_ERR_BADARGS;
break;
switch (i) {
case 0:
str_replace(&options->ssl.ca_cert_file, p);
break;
case 1:
str_replace(&options->ssl.certs_file, p);
break;
case 2:
str_replace(&options->ssl.private_key_file, p);
break;
case 3:
str_replace(&options->ssl.key_password, p);
break;
case 4:
str_replace(&options->ssl.dh_key_file, p);
break;
case 5:
str_replace(&options->ssl.ciphersuite, p);
break;
default:
fprintf(stderr, "Error: invalid ssl specification.");
rc = X11SPICE_ERR_BADARGS;
break;
}
}
......@@ -202,7 +203,7 @@ static int options_handle_ssl(options_t *options, const char *spec)
}
static void options_handle_ssl_file_options(options_t *options,
GKeyFile *userkey, GKeyFile *systemkey)
GKeyFile *userkey, GKeyFile *systemkey)
{
options->ssl.enabled = bool_option(userkey, systemkey, "ssl", "enabled");
string_option(&options->ssl.ca_cert_file, userkey, systemkey, "ssl", "ca-cert-file");
......@@ -218,13 +219,14 @@ static int options_parse_arguments(int argc, char *argv[], options_t *options)
int rc;
int longindex = 0;
enum option_types { OPTION_ALLOW_CONTROL, OPTION_DISALLOW_CONTROL,
OPTION_TIMEOUT, OPTION_AUTO, OPTION_HIDE,
OPTION_PASSWORD, OPTION_PASSWORD_FILE, OPTION_CONFIG, OPTION_SSL,
OPTION_GENERATE_PASSWORD, OPTION_DISPLAY, OPTION_MINIMIZE,
OPTION_HELP
enum option_types { OPTION_ALLOW_CONTROL, OPTION_DISALLOW_CONTROL,
OPTION_TIMEOUT, OPTION_AUTO, OPTION_HIDE,
OPTION_PASSWORD, OPTION_PASSWORD_FILE, OPTION_CONFIG, OPTION_SSL,
OPTION_GENERATE_PASSWORD, OPTION_DISPLAY, OPTION_MINIMIZE,
OPTION_HELP
};
/* *INDENT-OFF* - Prevent indent from shifting style on us */
static struct option long_options[] =
{
{"allow-control", 0, 0, OPTION_ALLOW_CONTROL },
......@@ -242,6 +244,7 @@ static int options_parse_arguments(int argc, char *argv[], options_t *options)
{"help", 0, 0, OPTION_HELP},
{0, 0, 0, 0}
};
/* *INDENT-ON* */
optind = 1; /* Allow reuse of this function */
while (1) {
......@@ -252,60 +255,60 @@ static int options_parse_arguments(int argc, char *argv[], options_t *options)
}
switch (rc) {
case OPTION_ALLOW_CONTROL:
options->allow_control = 1;
break;
case OPTION_DISALLOW_CONTROL:
options->allow_control = 0;
break;
case OPTION_TIMEOUT:
options->timeout = atol(optarg);
break;
case OPTION_HIDE:
options->hide = 1;
break;
case OPTION_PASSWORD:
str_replace(&options->spice_password, optarg);
break;
case OPTION_PASSWORD_FILE:
str_replace(&options->password_file, optarg);
break;
case OPTION_CONFIG:
str_replace(&options->user_config_file, optarg);
break;
case OPTION_SSL:
options->ssl.enabled = 1;
if (optarg) {
rc = options_handle_ssl(options, optarg);
if (rc)
return rc;
}
break;
case OPTION_GENERATE_PASSWORD:
options->generate_password = DEFAULT_PASSWORD_LENGTH;
if (optarg)
options->generate_password = atol(optarg);
break;
case OPTION_DISPLAY:
str_replace(&options->display, optarg);
break;
case OPTION_MINIMIZE:
options->minimize = 1;
break;
default:
usage(argv[0]);
return X11SPICE_ERR_BADARGS;
case OPTION_ALLOW_CONTROL:
options->allow_control = 1;
break;
case OPTION_DISALLOW_CONTROL:
options->allow_control = 0;
break;
case OPTION_TIMEOUT:
options->timeout = atol(optarg);
break;
case OPTION_HIDE:
options->hide = 1;
break;
case OPTION_PASSWORD:
str_replace(&options->spice_password, optarg);
break;
case OPTION_PASSWORD_FILE:
str_replace(&options->password_file, optarg);
break;
case OPTION_CONFIG:
str_replace(&options->user_config_file, optarg);
break;
case OPTION_SSL:
options->ssl.enabled = 1;
if (optarg) {
rc = options_handle_ssl(options, optarg);
if (rc)
return rc;
}
break;
case OPTION_GENERATE_PASSWORD:
options->generate_password = DEFAULT_PASSWORD_LENGTH;
if (optarg)
options->generate_password = atol(optarg);
break;
case OPTION_DISPLAY:
str_replace(&options->display, optarg);
break;
case OPTION_MINIMIZE:
options->minimize = 1;
break;
default:
usage(argv[0]);
return X11SPICE_ERR_BADARGS;
}
}
......@@ -317,7 +320,7 @@ static int options_parse_arguments(int argc, char *argv[], options_t *options)
count += options->generate_password ? 1 : 0;
if (count > 1) {
fprintf(stderr, "Error: you can specify only one of password, password-file, "
"and generate-password\n");
"and generate-password\n");
rc = X11SPICE_ERR_BADARGS;
}
}
......@@ -348,7 +351,8 @@ static void options_from_config(options_t *options)
int config_file_given = options->user_config_file ? TRUE : FALSE;
if (!config_file_given) {
options->user_config_file = g_build_filename(g_get_user_config_dir(), "x11spice/x11spice.conf", NULL);
options->user_config_file =
g_build_filename(g_get_user_config_dir(), "x11spice/x11spice.conf", NULL);
systemkey = g_key_file_new();
if (!g_key_file_load_from_dirs(systemkey, "x11spice/x11spice.conf",
......@@ -419,8 +423,7 @@ static int process_password_file(options_t *options)
printf("Enter password: ");
fflush(stdout);
fp = stdin;
}
else {
} else {
fp = fopen(options->password_file, "r");
if (!fp)
return X11SPICE_ERR_OPEN;
......@@ -496,7 +499,7 @@ int options_load(options_t *options, int argc, char *argv[])
if (rc == 0) {
options_from_config(options);
/* We parse command line arguments a second time to ensure
** that command line options take precedence over config files */
** that command line options take precedence over config files */
rc = options_parse_arguments(argc, argv, options);
if (rc == 0)
rc = options_process_io(options);
......
......@@ -30,7 +30,7 @@
** Structure definitions
**--------------------------------------------------------------------------*/
typedef struct {
int enabled;
int enabled;
char *ca_cert_file;
char *certs_file;
char *private_key_file;
......
......@@ -147,16 +147,14 @@ static void handle_scan_report(session_t *session, scan_report_t *r)
g_async_queue_push(session->draw_queue, drawable);
spice_qxl_wakeup(&session->spice.display_sin);
/*
** NOTE: the shmi is intentionally not freed at this point.
** The call path will take care of that once it's been
** pushed to Spice.
*/
** NOTE: the shmi is intentionally not freed at this point.
** The call path will take care of that once it's been
** pushed to Spice.
*/
return;
}
else
} else
g_debug("Unexpected failure to create drawable");
}
else
} else
g_debug("Unexpected failure to read shm of area %dx%d", r->w, r->h);
if (shmi)
......@@ -197,8 +195,7 @@ static void push_tiles_report(scanner_t *scanner, int start_row, int start_col,
static void grow_changed_tiles(scanner_t *scanner G_GNUC_UNUSED,
int *tiles_changed_in_row,
int tiles_changed[][NUM_HORIZONTAL_TILES],
int num_vertical_tiles)
int tiles_changed[][NUM_HORIZONTAL_TILES], int num_vertical_tiles)
{
int i;
int j;
......@@ -242,7 +239,8 @@ static void grow_changed_tiles(scanner_t *scanner G_GNUC_UNUSED,
}
}
static void push_changes_across_rows(scanner_t *scanner, int *tiles_changed_in_row, int num_vertical_tiles)
static void push_changes_across_rows(scanner_t *scanner, int *tiles_changed_in_row,
int num_vertical_tiles)
{
int i = 0;
int start_row = -1;
......@@ -253,8 +251,7 @@ static void push_changes_across_rows(scanner_t *scanner, int *tiles_changed_in_r
if (start_row == -1)
start_row = i;
current_row = i;
}
else {
} else {
if (current_row != -1) {
push_tiles_report(scanner, start_row, 0, current_row, NUM_HORIZONTAL_TILES - 1);
start_row = current_row = -1;
......@@ -291,8 +288,7 @@ static void push_changes_in_one_row(scanner_t *scanner, int row, int *tiles_chan
}
static void push_changed_tiles(scanner_t *scanner, int *tiles_changed_in_row,
int tiles_changed[][NUM_HORIZONTAL_TILES],
int num_vertical_tiles)
int tiles_changed[][NUM_HORIZONTAL_TILES], int num_vertical_tiles)
{
int i = 0;
......@@ -456,19 +452,16 @@ int scanner_push(scanner_t *scanner, scan_type_t type, int x, int y, int w, int
pixman_region_union_rect(&scanner->region, &scanner->region, x, y, w, h);
g_async_queue_push(scanner->queue, r);
}
else {
} else {
free(r);
}
rc = 0;
}
else {
} else {
free(r);
rc = X11SPICE_ERR_SHUTTING_DOWN;
}
g_mutex_unlock(scanner->lock);
}
#if defined(DEBUG_SCANLINES)
fprintf(stderr, "scan: type %d, %dx%d @ %dx%d\n", type, w, h, x, y);
fflush(stderr);
......
......@@ -129,7 +129,7 @@ int session_cursor_waiting(session_t *session)
void session_handle_key(session_t *session, uint8_t keycode, int is_press)
{
if (! session->options.allow_control)
if (!session->options.allow_control)
return;
xcb_test_fake_input(session->display.c, is_press ? XCB_KEY_PRESS : XCB_KEY_RELEASE,
......@@ -141,7 +141,7 @@ void session_handle_key(session_t *session, uint8_t keycode, int is_press)
void session_handle_mouse_position(session_t *session, int x, int y,
uint32_t buttons_state G_GNUC_UNUSED)
{
if (! session->options.allow_control)
if (!session->options.allow_control)
return;
xcb_test_fake_input(session->display.c, XCB_MOTION_NOTIFY, 0, XCB_CURRENT_TIME,
......@@ -153,7 +153,7 @@ void session_handle_mouse_position(session_t *session, int x, int y,
static void session_handle_button_change(session_t *s, uint32_t buttons_state)
{
int i;
if (! s->options.allow_control)
if (!s->options.allow_control)
return;
for (i = 0; i < BUTTONS; i++) {
......@@ -176,7 +176,7 @@ static uint32_t convert_spice_buttons(int wheel, uint32_t buttons_state)
(buttons_state & ~(SPICE_MOUSE_BUTTON_MASK_LEFT | SPICE_MOUSE_BUTTON_MASK_MIDDLE
| SPICE_MOUSE_BUTTON_MASK_RIGHT));
return buttons_state | (wheel > 0 ? (1 << 4) : 0)
| (wheel < 0 ? (1 << 3) : 0);
| (wheel < 0 ? (1 << 3) : 0);
}
......@@ -258,19 +258,15 @@ static int begin_audit(session_t *s)
int rc = X11SPICE_ERR_NOAUDIT;
#if defined(HAVE_LIBAUDIT) && defined(HAVE_LIBAUDIT_H)
s->audit_id = audit_open();
if (s->audit_id != -1)
{
if (s->audit_id != -1) {
rc = audit_log_user_message(s->audit_id, s->options.audit_message_type,
"x11spice begin", NULL, NULL, NULL, 1);
if (rc <= 0)
{
"x11spice begin", NULL, NULL, NULL, 1);
if (rc <= 0) {
perror("audit_log_user_message");
rc = X11SPICE_ERR_NOAUDIT;
}
else
} else
rc = 0;
}
else
} else
perror("audit_open");
#else
fprintf(stderr, "Error: audit requested, but not libaudit available.\n");
......@@ -281,10 +277,9 @@ static int begin_audit(session_t *s)
static void end_audit(session_t *s)
{
#if defined(HAVE_LIBAUDIT) && defined(HAVE_LIBAUDIT_H)
if (s->audit_id != -1)
{
if (s->audit_id != -1) {
audit_log_user_message(s->audit_id, s->options.audit_message_type,
"x11spice close", NULL, NULL, NULL, 1);
"x11spice close", NULL, NULL, NULL, 1);
audit_close(s->audit_id);
}
s->audit_id = -1;
......@@ -441,7 +436,8 @@ int session_get_one_led(session_t *session, const char *name)
XCB_XKB_ID_DFLT_XI_ID, atom_reply->atom);
free(atom_reply);
indicator_reply = xcb_xkb_get_named_indicator_reply(session->display.c, indicator_cookie, &error);
indicator_reply =
xcb_xkb_get_named_indicator_reply(session->display.c, indicator_cookie, &error);
if (error) {
g_warning("Could not get indicator; type %d; code %d; major %d; minor %d",
error->response_type, error->error_code, error->major_code, error->minor_code);
......@@ -456,12 +452,12 @@ int session_get_one_led(session_t *session, const char *name)
void session_disconnect_client(session_t *session)
{
/*
** TODO: This is using a side effect of set_ticket that is not intentional.
** It would be better to ask for a deliberate method of achieving this result.
*/
** TODO: This is using a side effect of set_ticket that is not intentional.
** It would be better to ask for a deliberate method of achieving this result.
*/
g_debug("client disconnect");
spice_server_set_ticket(session->spice.server, session->options.spice_password, 0, 0, TRUE);
if (! session->options.spice_password || session->options.disable_ticketing)
if (!session->options.spice_password || session->options.disable_ticketing)
spice_server_set_noauth(session->spice.server);
}
......@@ -470,10 +466,9 @@ static void invoke_on_connect(session_t *session, const char *from)
if (session->connect_pid)
cleanup_process(session->connect_pid);
session->connect_pid = fork();
if (session->connect_pid == 0)
{