Skip to content

Commit

Permalink
Fixed some things that clang static analysis complained about.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Oct 24, 2011
1 parent bc06f85 commit 77d450f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
3 changes: 0 additions & 3 deletions checksum_sha1.c
Expand Up @@ -95,8 +95,6 @@ static void MojoSha1_transform(uint32 state[5], const uint8 buffer[64])
state[2] += c;
state[3] += d;
state[4] += e;
/* Wipe variables */
a = b = c = d = e = 0;
}


Expand Down Expand Up @@ -157,7 +155,6 @@ void MojoSha1_finish(MojoSha1 *context, uint8 digest[20])
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}
/* Wipe variables */
i = j = 0;
memset(context->buffer, 0, 64);
memset(context->state, 0, 20);
memset(context->count, 0, 8);
Expand Down
7 changes: 4 additions & 3 deletions gui_stdio.c
Expand Up @@ -271,11 +271,12 @@ static void dumb_pager(const char *name, const char *data, size_t datalen)
printf("\n");
} // else
} while (!getout);

for (i = 0; i < linecount; i++)
free(lines[i]);
free(lines);
} // while

for (i = 0; i < linecount; i++)
free(lines[i]);
free(lines);
free(fmt);
} // dumb_pager

Expand Down
3 changes: 2 additions & 1 deletion lua_glue.c
Expand Up @@ -885,9 +885,10 @@ static int luahook_copyfile(lua_State *L)

static int luahook_stringtofile(lua_State *L)
{
const char *str = luaL_checkstring(L, 1);
const char *str = NULL;
MojoInput *in = NULL;
size_t len = 0;
luaL_checkstring(L, 1);
str = lua_tolstring(L, 1, &len);
in = MojoInput_newFromMemory((const uint8 *) str, (uint32) len, 1);
assert(in != NULL); // xmalloc() would fatal(), should not return NULL.
Expand Down
15 changes: 7 additions & 8 deletions platform_unix.c
Expand Up @@ -196,7 +196,6 @@ static char *realpathInternal(char *path, const char *cwd, int linkloop)
else if (strcmp(path, ".") == 0)
{
retval[--len] = '\0'; // chop ending "/." bit
newlen = 0;
} // else if

else if (strcmp(path, "..") == 0)
Expand All @@ -214,7 +213,6 @@ static char *realpathInternal(char *path, const char *cwd, int linkloop)
*ptr = '\0';
len -= (size_t) ((retval+len)-ptr);
} // else
newlen = 0;
} // else if

// it may be a symlink...check it.
Expand Down Expand Up @@ -299,7 +297,7 @@ char *MojoPlatform_realpath(const char *_path)
static char *findBinaryInPath(const char *bin)
{
const char *_envr = getenv("PATH");
size_t alloc_size = 0;
size_t alloc_size = 64;
char *envr = NULL;
char *exe = NULL;
char *start = NULL;
Expand All @@ -309,6 +307,7 @@ static char *findBinaryInPath(const char *bin)
return NULL;

envr = xstrdup(_envr);
exe = (char *) xmalloc(alloc_size);
start = envr;

do
Expand Down Expand Up @@ -342,12 +341,10 @@ static char *findBinaryInPath(const char *bin)
start = ptr + 1; // start points to beginning of next element.
} while (ptr != NULL);

if (exe != NULL)
free(exe);

free(exe);
free(envr);

return(NULL); // doesn't exist in path.
return NULL; // doesn't exist in path.
} // findBinaryInPath


Expand Down Expand Up @@ -1057,7 +1054,9 @@ static int runScriptString(const char *str, boolean devnull, const char **_argv)
failed |= (close(pipes[1]) == -1);

// !!! FIXME: we need a GGui->pump() or something here if we'll block.
if (waitpid(pid, &status, 0) != -1)
failed |= (waitpid(pid, &status, 0) == -1);

if (!failed)
{
if (WIFEXITED(status))
retval = WEXITSTATUS(status);
Expand Down
1 change: 0 additions & 1 deletion stb_image.c
Expand Up @@ -2373,7 +2373,6 @@ static int compute_transparency(uint8 tc[3], int out_n)
// already got 255 as the alpha value in the output
assert(out_n == 2 || out_n == 4);

p = out;
if (out_n == 2) {
for (i=0; i < pixel_count; ++i) {
p[1] = (p[0] == tc[0] ? 0 : 255);
Expand Down

0 comments on commit 77d450f

Please sign in to comment.