Small cleanups

This commit is contained in:
Twinaphex 2012-08-20 12:04:32 +02:00
parent 6c500b45d5
commit ad576f18f5
8 changed files with 72 additions and 90 deletions

View File

@ -16,8 +16,8 @@
#include "file_browser.h"
static bool filebrowser_parse_directory(filebrowser_t * filebrowser, unsigned stack_size,
const char * path, const char * extensions)
static bool filebrowser_parse_directory(filebrowser_t *filebrowser, unsigned stack_size,
const char *path, const char * extensions)
{
struct string_list *list = dir_list_new(path, extensions, true);
@ -31,6 +31,8 @@ const char * path, const char * extensions)
filebrowser->current_dir.list = list;
filebrowser->current_dir.ptr = 0;
filebrowser->directory_stack_size = stack_size;
strlcpy(filebrowser->extensions, extensions, sizeof(filebrowser->extensions));
dir_list_sort(filebrowser->current_dir.list, true);
@ -40,18 +42,10 @@ const char * path, const char * extensions)
return false;
}
static bool filebrowser_new(filebrowser_t * filebrowser, const char * start_dir,
const char * extensions)
static bool filebrowser_new(filebrowser_t *filebrowser, const char *start_dir,
const char *extensions)
{
bool ret = true;
ret = filebrowser_parse_directory(filebrowser, 0, start_dir, extensions);
if(ret)
{
filebrowser->directory_stack_size = 0;
strlcpy(filebrowser->extensions, extensions, sizeof(filebrowser->extensions));
}
bool ret = filebrowser_parse_directory(filebrowser, 0, start_dir, extensions);
return ret;
}
@ -81,9 +75,7 @@ bool with_extension)
{
bool ret = true;
char extensions[256];
unsigned push_dir;
push_dir = filebrowser->directory_stack_size + 1;
unsigned push_dir = filebrowser->directory_stack_size + 1;
if(with_extension)
snprintf(extensions, sizeof(extensions), filebrowser->extensions);
@ -92,37 +84,29 @@ bool with_extension)
ret = filebrowser_parse_directory(filebrowser, push_dir, path, extensions);
if(ret)
filebrowser->directory_stack_size = push_dir;
return ret;
}
static bool filebrowser_pop_directory (filebrowser_t * filebrowser)
{
bool ret = true;
unsigned pop_dir;
unsigned pop_dir = filebrowser->directory_stack_size;
if (filebrowser->directory_stack_size > 0)
pop_dir = filebrowser->directory_stack_size - 1;
else
pop_dir = filebrowser->directory_stack_size;
pop_dir -= 1;
ret = filebrowser_parse_directory(filebrowser, pop_dir, filebrowser->dir[pop_dir],
filebrowser->extensions);
if(ret)
filebrowser->directory_stack_size = pop_dir;
return ret;
}
const char * filebrowser_get_current_dir (filebrowser_t *filebrowser)
const char *filebrowser_get_current_dir (filebrowser_t *filebrowser)
{
return filebrowser->dir[filebrowser->directory_stack_size];
}
const char * filebrowser_get_current_path (filebrowser_t *filebrowser)
const char *filebrowser_get_current_path (filebrowser_t *filebrowser)
{
return filebrowser->current_dir.list->elems[filebrowser->current_dir.ptr].data;
}
@ -158,7 +142,7 @@ static void filebrowser_set_current_decrement (filebrowser_t *filebrowser, bool
bool filebrowser_iterate(filebrowser_t *filebrowser, filebrowser_action_t action)
{
static bool ret = true;
bool ret = true;
unsigned entries_to_scroll = 19;
switch(action)

View File

@ -25,11 +25,11 @@
typedef struct
{
uint32_t directory_stack_size;
unsigned char directory_stack_size;
char dir[MAX_DIR_STACK][PATH_MAX];
struct {
struct string_list *list;
size_t ptr;
struct string_list *list;
size_t ptr;
} current_dir;
char root_dir[PATH_MAX];
char extensions[PATH_MAX];

View File

@ -61,7 +61,6 @@
#define close(x) socketclose(x)
/*
****************************************************************************
Naming convention. Functions for use in API are called rsd_*(), *
@ -241,7 +240,7 @@ static int rsnd_connect_server( rsound_t *rd )
/* Cleanup for errors. */
error:
RSD_ERR("Connecting to server failed. \"%s\"", rd->host);
RSD_ERR("[RSound] Connecting to server failed. \"%s\"", rd->host);
return -1;
}
@ -255,7 +254,7 @@ static int rsnd_send_header_info(rsound_t *rd)
char *header = calloc(1, HEADER_SIZE);
if (header == NULL)
{
RSD_ERR("Could not allocate memory.");
RSD_ERR("[RSound] Could not allocate memory.");
return -1;
}
uint16_t temp16;
@ -311,7 +310,6 @@ static int rsnd_send_header_info(rsound_t *rd)
break;
}
/* Since the values in the wave header we are interested in, are little endian (>_<), we need
to determine whether we're running it or not, so we can byte swap accordingly.
Could determine this compile time, but it was simpler to do it this way. */
@ -406,7 +404,7 @@ static int rsnd_get_backend_info ( rsound_t *rd )
if ( rsnd_recv_chunk(rd->conn.socket, rsnd_header, RSND_HEADER_SIZE, 1) != RSND_HEADER_SIZE )
{
RSD_ERR("Couldn't receive chunk.");
RSD_ERR("[RSound] Couldn't receive chunk.\n");
return -1;
}
@ -434,7 +432,7 @@ static int rsnd_get_backend_info ( rsound_t *rd )
rd->fifo_buffer = fifo_new (rd->buffer_size);
if ( rd->fifo_buffer == NULL )
{
RSD_ERR("Failed to create fifobuf");
RSD_ERR("[RSound] Failed to create FIFO buffer.\n");
return -1;
}
@ -463,7 +461,7 @@ static int rsnd_get_backend_info ( rsound_t *rd )
if ( rsnd_recv_chunk(rd->conn.socket, rsnd_header, RSND_HEADER_SIZE, 0) == RSND_HEADER_SIZE )
rd->conn_type |= RSD_CONN_PROTO;
else
{ RSD_DEBUG("Failed to get new proto"); }
{ RSD_DEBUG("[RSound] Failed to get new proto.\n"); }
// We no longer want to read from this socket.
#ifdef _WIN32
@ -487,7 +485,7 @@ static int rsnd_create_connection(rsound_t *rd)
rc = rsnd_connect_server(rd);
if (rc < 0)
{
RSD_ERR("connect server failed!");
RSD_ERR("[RSound] connect server failed.\n");
rsd_stop(rd);
return -1;
}
@ -500,14 +498,14 @@ static int rsnd_create_connection(rsound_t *rd)
if ( rsnd_poll(&fd, 1, 2000) < 0 )
{
RSD_ERR("rsnd_poll failed!");
RSD_ERR("[RSound] rsnd_poll failed.\n");
rsd_stop(rd);
return -1;
}
if ( !(fd.revents & POLLOUT) )
{
RSD_ERR("Poll didn't return what we wanted!");
RSD_ERR("[RSound] Poll didn't return what we wanted.\n");
rsd_stop(rd);
return -1;
}
@ -523,7 +521,7 @@ static int rsnd_create_connection(rsound_t *rd)
rc = rsnd_send_header_info(rd);
if (rc < 0)
{
RSD_ERR("Send header failed!");
RSD_ERR("[RSound] Send header failed.\n");
rsd_stop(rd);
return -1;
}
@ -531,7 +529,7 @@ static int rsnd_create_connection(rsound_t *rd)
rc = rsnd_get_backend_info(rd);
if (rc < 0)
{
RSD_ERR("Get backend info failed!");
RSD_ERR("[RSound] Get backend info failed.\n");
rsd_stop(rd);
return -1;
}
@ -539,7 +537,7 @@ static int rsnd_create_connection(rsound_t *rd)
rc = rsnd_start_thread(rd);
if (rc < 0)
{
RSD_ERR("Starting thread failed!");
RSD_ERR("[RSound] Starting thread failed.\n");
rsd_stop(rd);
return -1;
}
@ -589,7 +587,7 @@ static ssize_t rsnd_send_chunk(int socket, const void* buf, size_t size, int blo
rc = send(socket, (const char*)buf + wrote, send_size, 0);
if ( rc < 0 )
{
RSD_ERR("Error sending chunk, %s\n", strerror(errno));
RSD_ERR("[RSound] Error sending chunk, %s.\n", strerror(errno));
return rc;
}
wrote += rc;
@ -625,13 +623,13 @@ static ssize_t rsnd_recv_chunk(int socket, void *buf, size_t size, int blocking)
{
if ( rsnd_poll(&fd, 1, sleep_time) < 0 )
{
RSD_ERR("Poll failed");
RSD_ERR("[RSound] Poll failed.\n");
return -1;
}
if ( fd.revents & POLLHUP )
{
RSD_ERR("Server hung up");
RSD_ERR("[RSound] Server hung up.\n");
return -1;
}
@ -641,7 +639,7 @@ static ssize_t rsnd_recv_chunk(int socket, void *buf, size_t size, int blocking)
rc = recv(socket, (char*)buf + has_read, read_size, 0);
if ( rc <= 0 )
{
RSD_ERR("Error receiving chunk, %s\n", strerror(errno));
RSD_ERR("[RSound] Error receiving chunk, %s.\n", strerror(errno));
return rc;
}
has_read += rc;
@ -650,7 +648,7 @@ static ssize_t rsnd_recv_chunk(int socket, void *buf, size_t size, int blocking)
{
if ( blocking )
{
RSD_ERR("Block FAIL!");
RSD_ERR("[RSound] Block fail.\n");
return -1;
}
else
@ -735,19 +733,19 @@ static size_t rsnd_fill_buffer(rsound_t *rd, const char *buf, size_t size)
pthread_mutex_lock(&rd->thread.cond_mutex);
pthread_cond_signal(&rd->thread.cond);
RSD_DEBUG("rsnd_fill_buffer: Going to sleep.");
RSD_DEBUG("[RSound] rsnd_fill_buffer: Going to sleep.\n");
pthread_cond_wait(&rd->thread.cond, &rd->thread.cond_mutex);
RSD_DEBUG("rsnd_fill_buffer: Woke up.");
RSD_DEBUG("[RSound] rsnd_fill_buffer: Woke up.\n");
pthread_mutex_unlock(&rd->thread.cond_mutex);
}
pthread_mutex_lock(&rd->thread.mutex);
fifo_write(rd->fifo_buffer, buf, size);
pthread_mutex_unlock(&rd->thread.mutex);
//RSD_DEBUG("fill_buffer: Wrote to buffer.");
//RSD_DEBUG("[RSound] fill_buffer: Wrote to buffer.\n");
/* Send signal to thread that buffer has been updated */
//RSD_DEBUG("fill_buffer: Waking up thread.");
//RSD_DEBUG("[RSound] fill_buffer: Waking up thread.\n");
pthread_cond_signal(&rd->thread.cond);
return size;
@ -763,7 +761,7 @@ static int rsnd_start_thread(rsound_t *rd)
if ( rc < 0 )
{
rd->thread_active = 0;
RSD_ERR("Failed to create thread.");
RSD_ERR("[RSound] Failed to create thread.");
return -1;
}
return 0;
@ -778,7 +776,7 @@ static int rsnd_stop_thread(rsound_t *rd)
if ( rd->thread_active )
{
RSD_DEBUG("Shutting down thread.");
RSD_DEBUG("[RSound] Shutting down thread.\n");
pthread_mutex_lock(&rd->thread.cond_mutex);
rd->thread_active = 0;
@ -786,15 +784,15 @@ static int rsnd_stop_thread(rsound_t *rd)
pthread_mutex_unlock(&rd->thread.cond_mutex);
if ( pthread_join(rd->thread.threadId, NULL) < 0 )
RSD_WARN("*** Warning, did not terminate thread. ***");
RSD_WARN("[RSound] *** Warning, did not terminate thread. ***\n");
else
RSD_DEBUG("Thread joined successfully.");
RSD_DEBUG("[RSound] Thread joined successfully.\n");
return 0;
}
else
{
RSD_DEBUG("Thread is already shut down.");
RSD_DEBUG("Thread is already shut down.\n");
return 0;
}
}
@ -811,7 +809,7 @@ static size_t rsnd_get_delay(rsound_t *rd)
pthread_mutex_lock(&rd->thread.mutex);
ptr += rd->delay_offset;
RSD_DEBUG("Offset: %d", rd->delay_offset);
RSD_DEBUG("Offset: %d.\n", rd->delay_offset);
pthread_mutex_unlock(&rd->thread.mutex);
if ( ptr < 0 )
@ -1005,7 +1003,7 @@ static int rsnd_update_server_info(rsound_t *rd)
delta += fifo_read_avail(rd->fifo_buffer);
pthread_mutex_unlock(&rd->thread.mutex);
RSD_DEBUG("Delay: %d, Delta: %d", delay, delta);
RSD_DEBUG("[RSound] Delay: %d, Delta: %d.\n", delay, delta);
// We only update the pointer if the data we got is quite recent.
if ( rd->total_written - client_ptr < 4 * rd->backend_info.chunk_size && rd->total_written > client_ptr )
@ -1020,7 +1018,7 @@ static int rsnd_update_server_info(rsound_t *rd)
pthread_mutex_lock(&rd->thread.mutex);
rd->delay_offset += offset_delta;
pthread_mutex_unlock(&rd->thread.mutex);
RSD_DEBUG("Changed offset-delta: %d", offset_delta);
RSD_DEBUG("[RSound] Changed offset-delta: %d.\n", offset_delta);
}
}
@ -1116,13 +1114,13 @@ static void* rsnd_thread ( void * thread_data )
if ( rd->thread_active )
{
RSD_DEBUG("Thread going to sleep.");
RSD_DEBUG("[RSound] Thread going to sleep.\n");
pthread_cond_wait(&rd->thread.cond, &rd->thread.cond_mutex);
RSD_DEBUG("Thread woke up.");
RSD_DEBUG("[RSound] Thread woke up.\n");
}
pthread_mutex_unlock(&rd->thread.cond_mutex);
RSD_DEBUG("Thread unlocked cond_mutex.");
RSD_DEBUG("[RSound] Thread unlocked cond_mutex.\n");
}
/* Abort request, chap. */
else
@ -1170,7 +1168,7 @@ static void* rsnd_cb_thread(void *thread_data)
{
if ((int)rsd_delay_ms(rd) < rd->max_latency / 2)
{
RSD_DEBUG("Callback thread: Requested %d bytes, got %d\n", (int)will_read, (int)ret);
RSD_DEBUG("[RSound] Callback thread: Requested %d bytes, got %d.\n", (int)will_read, (int)ret);
memset(buffer + has_read, 0, will_read - ret);
has_read += will_read - ret;
}
@ -1306,25 +1304,25 @@ int rsd_start(rsound_t *rsound)
int rsd_exec(rsound_t *rsound)
{
assert(rsound != NULL);
RSD_DEBUG("rsd_exec()");
RSD_DEBUG("[RSound] rsd_exec().\n");
// Makes sure we have a working connection
if ( rsound->conn.socket < 0 )
{
RSD_DEBUG("Calling rsd_start()");
RSD_DEBUG("[RSound] Calling rsd_start().\n");
if ( rsd_start(rsound) < 0 )
{
RSD_ERR("rsd_start() failed!");
RSD_ERR("[RSound] rsd_start() failed.\n");
return -1;
}
}
RSD_DEBUG("Closing ctl");
RSD_DEBUG("[RSound] Closing ctl.\n");
if ( rsnd_close_ctl(rsound) < 0 )
return -1;
int fd = rsound->conn.socket;
RSD_DEBUG("Socket: %d", fd);
RSD_DEBUG("[RSound] Socket: %d.\n", fd);
rsnd_stop_thread(rsound);
@ -1339,13 +1337,13 @@ int rsd_exec(rsound_t *rsound)
fifo_read(rsound->fifo_buffer, buffer, sizeof(buffer));
if ( rsnd_send_chunk(fd, buffer, sizeof(buffer), 1) != (ssize_t)sizeof(buffer) )
{
RSD_DEBUG("Failed flushing buffer!");
RSD_DEBUG("[RSound] Failed flushing buffer.\n");
close(fd);
return -1;
}
}
RSD_DEBUG("Returning from rsd_exec()");
RSD_DEBUG("[RSound] Returning from rsd_exec().\n");
rsd_free(rsound);
return fd;
}
@ -1445,7 +1443,7 @@ void rsd_delay_wait(rsound_t *rd)
if ( rd->max_latency < latency_ms )
{
int64_t sleep_ms = latency_ms - rd->max_latency;
RSD_DEBUG("Delay wait: %d ms\n", (int)sleep_ms);
RSD_DEBUG("[RSound] Delay wait: %d ms.\n", (int)sleep_ms);
rsnd_sleep((int)sleep_ms);
}
}

View File

@ -30,7 +30,7 @@ struct platform_bind
uint64_t rarch_default_keybind_lut[RARCH_FIRST_META_KEY];
char rarch_default_libretro_keybind_name_lut[RARCH_FIRST_META_KEY][256] = {
char rarch_default_libretro_keybind_name_lut[RARCH_FIRST_META_KEY][] = {
"RetroPad Button B", /* RETRO_DEVICE_ID_JOYPAD_B */
"RetroPad Button Y", /* RETRO_DEVICE_ID_JOYPAD_Y */
"RetroPad Button Select", /* RETRO_DEVICE_ID_JOYPAD_SELECT */

View File

@ -67,7 +67,7 @@ bool rarch_configure_libretro_core(const char *full_path, const char *tmp_path,
if (path_file_exists(full_path))
{
size_t sizeof_libretro_core = sizeof(libretro_core_installed);
char tmp_path2[1024], tmp_pathnewfile[1024];
char tmp_path2[PATH_MAX], tmp_pathnewfile[PATH_MAX];
rarch_console_name_from_id(tmp_path2, sizeof(tmp_path2));
strlcat(tmp_path2, extension, sizeof(tmp_path2));

View File

@ -50,7 +50,7 @@ struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = {
{ "Custom", 0.0f }
};
char rotation_lut[ASPECT_RATIO_END][PATH_MAX] =
char rotation_lut[ASPECT_RATIO_END][] =
{
"Normal",
"Vertical",

View File

@ -59,7 +59,6 @@ struct internal_state
inflate_blocks_statef *blocks; /* current inflate_blocks state */
};
const unsigned int border[] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
START, /* x: set up for LEN */
@ -147,8 +146,7 @@ inflate_codes_statef *inflate_codes_new(unsigned int bl, unsigned int bd, inflat
{
inflate_codes_statef *c;
if ((c = (inflate_codes_statef *)
ZALLOC(z,1,sizeof(struct inflate_codes_state))) != 0)
if ((c = (inflate_codes_statef *)ZALLOC(z,1,sizeof(struct inflate_codes_state))) != 0)
{
c->mode = START;
c->lbits = (Byte)bl;
@ -735,8 +733,8 @@ int inflate_trees_dynamic(unsigned int nl, unsigned int nd, unsigned int *c, uns
return Z_OK;
}
unsigned int fixed_bl = 9;
unsigned int fixed_bd = 5;
#define FIXED_BL 9
#define FIXED_BD 5
inflate_huft fixed_tl[] = {
{{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
@ -882,11 +880,12 @@ inflate_huft fixed_td[] = {
int inflate_trees_fixed(unsigned int * bl, unsigned int *bd, inflate_huft ** tl, inflate_huft ** td, z_streamp z)
{
*bl = fixed_bl;
*bd = fixed_bd;
*tl = fixed_tl;
*td = fixed_td;
return Z_OK;
*bl = FIXED_BL;
*bd = FIXED_BD;
*tl = fixed_tl;
*td = fixed_td;
return Z_OK;
}
/* infblock.c -- interpret and process block types to last block
@ -940,10 +939,11 @@ int inflate_blocks(inflate_blocks_statef *s, z_streamp z, int r)
unsigned int t; /* temporary storage */
unsigned long b; /* bit buffer */
unsigned int k; /* bits in bit buffer */
Bytef *p; /* input data pointer */
Bytef *p; /* input data pointer */
unsigned int n; /* bytes available there */
Bytef *q; /* output window write pointer */
Bytef *q; /* output window write pointer */
unsigned int m; /* bytes to end of window or read pointer */
const unsigned int border[] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
/* copy input/output information to locals (UPDATE macro restores) */
LOAD

View File

@ -579,7 +579,7 @@ static void gx_free(void *data)
(void)data;
}
static void gx_set_rotation(void * data, uint32_t orientation)
static void gx_set_rotation(void * data, unsigned orientation)
{
(void)data;
gx_video_t *gx = (gx_video_t*)driver.video_data;