mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
Random cleanups
This commit is contained in:
parent
cdec12faa5
commit
d4d76daa12
@ -77,7 +77,8 @@ static int parse_short(const char *optstring, char * const *argv)
|
||||
{
|
||||
bool extra_opt, takes_arg, embedded_arg;
|
||||
const char *opt = NULL;
|
||||
char arg = argv[0][1];
|
||||
char arg = argv[0][1];
|
||||
|
||||
if (arg == ':')
|
||||
return '?';
|
||||
|
||||
@ -161,8 +162,9 @@ static int parse_long(const struct option *longopts, char * const *argv)
|
||||
|
||||
static void shuffle_block(char **begin, char **last, char **end)
|
||||
{
|
||||
ptrdiff_t len = last - begin;
|
||||
ptrdiff_t len = last - begin;
|
||||
const char **tmp = (const char**)calloc(len, sizeof(const char*));
|
||||
|
||||
rarch_assert(tmp);
|
||||
|
||||
memcpy(tmp, begin, len * sizeof(const char*));
|
||||
@ -176,6 +178,7 @@ int getopt_long(int argc, char *argv[],
|
||||
const char *optstring, const struct option *longopts, int *longindex)
|
||||
{
|
||||
int short_index, long_index;
|
||||
|
||||
(void)longindex;
|
||||
|
||||
if (optind == 0)
|
||||
@ -222,6 +225,7 @@ int getopt_long(int argc, char *argv[],
|
||||
static int casencmp(const char *a, const char *b, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
int a_lower = tolower(a[i]);
|
||||
@ -275,6 +279,7 @@ size_t strlcpy(char *dest, const char *source, size_t size)
|
||||
size_t strlcat(char *dest, const char *source, size_t size)
|
||||
{
|
||||
size_t len = strlen(dest);
|
||||
|
||||
dest += len;
|
||||
|
||||
if (len > size)
|
||||
@ -306,6 +311,7 @@ int rarch_strcasecmp__(const char *a, const char *b)
|
||||
{
|
||||
int a_ = tolower(*a);
|
||||
int b_ = tolower(*b);
|
||||
|
||||
if (a_ != b_)
|
||||
return a_ - b_;
|
||||
|
||||
@ -319,7 +325,7 @@ int rarch_strcasecmp__(const char *a, const char *b)
|
||||
char *rarch_strdup__(const char *orig)
|
||||
{
|
||||
size_t len = strlen(orig) + 1;
|
||||
char *ret = (char*)malloc(len);
|
||||
char *ret = (char*)malloc(len);
|
||||
if (!ret)
|
||||
return NULL;
|
||||
|
||||
|
@ -501,7 +501,7 @@ static void SHA1Input(SHA1Context *context,
|
||||
|
||||
int sha1_calculate(const char *path, char *result)
|
||||
{
|
||||
unsigned char buff[4096];
|
||||
unsigned char buff[4096] = {0};
|
||||
SHA1Context sha;
|
||||
int rv = 1;
|
||||
int fd = open(path, O_RDONLY);
|
||||
|
@ -58,19 +58,19 @@ struct http_connection_t
|
||||
char *domain;
|
||||
char *location;
|
||||
char *urlcopy;
|
||||
char* scan;
|
||||
char *scan;
|
||||
int port;
|
||||
};
|
||||
|
||||
|
||||
static int net_http_new_socket(const char * domain, int port)
|
||||
static int net_http_new_socket(const char *domain, int port)
|
||||
{
|
||||
char portstr[16];
|
||||
int fd;
|
||||
#ifndef _WIN32
|
||||
struct timeval timeout;
|
||||
#endif
|
||||
struct addrinfo hints, *addr = NULL;
|
||||
char portstr[16] = {0};
|
||||
|
||||
snprintf(portstr, sizeof(portstr), "%i", port);
|
||||
|
||||
@ -276,7 +276,7 @@ struct http_t *net_http_new(struct http_connection_t *conn)
|
||||
|
||||
if (conn->port != 80)
|
||||
{
|
||||
char portstr[16];
|
||||
char portstr[16] = {0};
|
||||
|
||||
snprintf(portstr, sizeof(portstr), ":%i", conn->port);
|
||||
net_http_send_str(fd, &error, portstr);
|
||||
|
@ -46,10 +46,10 @@ char *string_to_upper(char *s)
|
||||
|
||||
char *string_replace_substring(const char *in, const char *pattern, const char *replacement)
|
||||
{
|
||||
char *needle = NULL;
|
||||
char *newstr = NULL;
|
||||
char *head = NULL;
|
||||
size_t pattern_len = 0;
|
||||
char *needle = NULL;
|
||||
char *newstr = NULL;
|
||||
char *head = NULL;
|
||||
size_t pattern_len = 0;
|
||||
size_t replacement_len = 0;
|
||||
|
||||
/* if either pattern or replacement is NULL,
|
||||
@ -57,18 +57,19 @@ char *string_replace_substring(const char *in, const char *pattern, const char *
|
||||
if (!pattern || !replacement)
|
||||
return strdup(in);
|
||||
|
||||
pattern_len = strlen(pattern);
|
||||
pattern_len = strlen(pattern);
|
||||
replacement_len = strlen(replacement);
|
||||
|
||||
newstr = strdup(in);
|
||||
head = newstr;
|
||||
newstr = strdup(in);
|
||||
head = newstr;
|
||||
|
||||
while ((needle = strstr(head, pattern)))
|
||||
{
|
||||
char* oldstr = newstr;
|
||||
char *oldstr = newstr;
|
||||
size_t oldstr_len = strlen(oldstr);
|
||||
|
||||
newstr = (char*)malloc(oldstr_len - pattern_len + replacement_len + 1);
|
||||
|
||||
if (!newstr)
|
||||
{
|
||||
/* Failed to allocate memory,
|
||||
|
@ -108,7 +108,8 @@ struct string_list *string_list_new(void)
|
||||
bool string_list_append(struct string_list *list, const char *elem,
|
||||
union string_list_elem_attr attr)
|
||||
{
|
||||
char *data_dup;
|
||||
char *data_dup = NULL;
|
||||
|
||||
if (list->size >= list->cap &&
|
||||
!string_list_capacity(list, list->cap * 2))
|
||||
return false;
|
||||
@ -250,7 +251,7 @@ bool string_list_find_elem_prefix(const struct string_list *list,
|
||||
const char *prefix, const char *elem)
|
||||
{
|
||||
size_t i;
|
||||
char prefixed[PATH_MAX_LENGTH];
|
||||
char prefixed[PATH_MAX_LENGTH] = {0};
|
||||
|
||||
if (!list)
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user