Remove unnecessary (char *) casts

This commit is contained in:
Jeremy Baxter 2023-07-01 19:29:22 +12:00
parent be27e32ad2
commit 97f527fde8
3 changed files with 21 additions and 21 deletions

6
lcl.c
View file

@ -24,7 +24,7 @@ static void
fmesg(lua_State *L, FILE* f, int shift) fmesg(lua_State *L, FILE* f, int shift)
{ {
int paramc, i; int paramc, i;
char *progname; /* argv[0] */ const char *progname; /* argv[0] */
paramc = lua_gettop(L); /* get parameter count */ paramc = lua_gettop(L); /* get parameter count */
@ -32,7 +32,7 @@ fmesg(lua_State *L, FILE* f, int shift)
if (lua_type(L, -1) != LUA_TSTRING) { /* if argv[0] is not a string... */ if (lua_type(L, -1) != LUA_TSTRING) { /* if argv[0] is not a string... */
luaL_error(L, "invalid argument table passed (must have an string in index [0])"); luaL_error(L, "invalid argument table passed (must have an string in index [0])");
} }
progname = (char *)lua_tostring(L, -1); /* set progname to argv[0] */ progname = lua_tostring(L, -1); /* set progname to argv[0] */
/* format using string.format */ /* format using string.format */
lua_getglobal(L, "string"); lua_getglobal(L, "string");
@ -229,7 +229,7 @@ cl_parseopts(lua_State *L)
/* parameter type checking */ /* parameter type checking */
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
strlcpy(optstring, (char *)luaL_checkstring(L, 2), lua_rawlen(L, 2) * sizeof(char *)); strlcpy(optstring, luaL_checkstring(L, 2), lua_rawlen(L, 2) * sizeof(char *));
luaL_checktype(L, 3, LUA_TFUNCTION); luaL_checktype(L, 3, LUA_TFUNCTION);
argc = (int)lua_rawlen(L, 1) + 1; /* get argv length */ argc = (int)lua_rawlen(L, 1) + 1; /* get argv length */

22
lfile.c
View file

@ -38,11 +38,11 @@
static int static int
file_basename(lua_State *L) file_basename(lua_State *L)
{ {
char *path; /* parameter 1 (string) */ const char *path; /* parameter 1 (string) */
char *ret; const char *ret;
path = (char *)luaL_checkstring(L, 1); path = luaL_checkstring(L, 1);
ret = basename(path); ret = basename(path);
if (ret == NULL && errno == ENAMETOOLONG) /* check if path is too long */ if (ret == NULL && errno == ENAMETOOLONG) /* check if path is too long */
return lfail(L, "pathname too long"); return lfail(L, "pathname too long");
@ -70,11 +70,11 @@ file_basename(lua_State *L)
static int static int
file_dirname(lua_State *L) file_dirname(lua_State *L)
{ {
char *path; /* parameter 1 (string) */ const char *path; /* parameter 1 (string) */
char *ret; const char *ret;
path = (char *)luaL_checkstring(L, 1); path = luaL_checkstring(L, 1);
ret = dirname(path); ret = dirname(path);
if (ret == NULL && errno == ENAMETOOLONG) /* check if path is too long */ if (ret == NULL && errno == ENAMETOOLONG) /* check if path is too long */
return lfail(L, "pathname too long"); return lfail(L, "pathname too long");
@ -269,8 +269,8 @@ file.workdir(environment.get("HOME"))
static int static int
file_workdir(lua_State *L) file_workdir(lua_State *L)
{ {
char *workdir; /* parameter 1 (string) */ const char *workdir; /* parameter 1 (string) */
char *buffer; /* buffer used by getcwd() */ char *buffer; /* buffer used by getcwd() */
char *ret; char *ret;
if (lua_isnoneornil(L, 1)) { /* if first argument was not given... */ if (lua_isnoneornil(L, 1)) { /* if first argument was not given... */
buffer = malloc(sizeof(char *) * 512); buffer = malloc(sizeof(char *) * 512);
@ -305,7 +305,7 @@ file_workdir(lua_State *L)
return 0; return 0;
} else { } else {
workdir = (char *)luaL_checkstring(L, 1); workdir = luaL_checkstring(L, 1);
if (chdir(workdir) == 0) { if (chdir(workdir) == 0) {
lua_pushboolean(L, 1); lua_pushboolean(L, 1);

View file

@ -93,12 +93,12 @@ static const char *signals[] = {
static int static int
process_pid(lua_State *L) process_pid(lua_State *L)
{ {
char *process; /* parameter 1 (string) */ const char *process; /* parameter 1 (string) */
char *command; /* pidof command buffer */ char *command; /* pidof command buffer */
char *buffer; /* pidof reading buffer */ char *buffer; /* pidof reading buffer */
long pid; /* pid to return to Lua */ long pid; /* pid to return to Lua */
size_t pidmax; /* length passed to getline */ size_t pidmax; /* length passed to getline */
ssize_t ret; /* return value of getline */ ssize_t ret; /* return value of getline */
FILE *p; FILE *p;
if (lua_isnoneornil(L, 1)) { /* check if first parameter wasn't given */ if (lua_isnoneornil(L, 1)) { /* check if first parameter wasn't given */
@ -106,7 +106,7 @@ process_pid(lua_State *L)
return 1; return 1;
} }
process = (char *)luaL_checkstring(L, 1); process = luaL_checkstring(L, 1);
command = calloc(1, PROCESS_MAX * sizeof(char *)); command = calloc(1, PROCESS_MAX * sizeof(char *));
/* construct pidof command */ /* construct pidof command */