summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-08-14 10:04:12 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-08-14 10:04:49 -0700
commit0c55e2eabe6755b88de9835da8185a52b7712847 (patch)
treeaee21c3293cdc5ccb8be6e99a773ef49f3326583
parent5fdd590f9b9a9f5aa3a60e44fe8f010c43f8c54e (diff)
Remove or correct obsolete casts
Bring code up to C89 levels Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--save.c28
-rw-r--r--smproxy.c12
2 files changed, 18 insertions, 22 deletions
diff --git a/save.c b/save.c
index 3d92183..738ada9 100644
--- a/save.c
+++ b/save.c
@@ -89,7 +89,7 @@ asprintf(char ** ret, const char *format, ...)
static int
write_byte (FILE *file, unsigned char b)
{
- if (fwrite ((char *) &b, 1, 1, file) != 1)
+ if (fwrite (&b, 1, 1, file) != 1)
return 0;
return 1;
}
@@ -102,7 +102,7 @@ write_short (FILE *file, unsigned short s)
file_short[0] = (s & (unsigned)0xff00) >> 8;
file_short[1] = s & 0xff;
- if (fwrite ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
+ if (fwrite (file_short, sizeof (file_short), 1, file) != 1)
return 0;
return 1;
}
@@ -113,11 +113,11 @@ write_counted_string(FILE *file, char *string)
{
if (string)
{
- unsigned char count = strlen (string);
+ size_t count = strlen (string);
- if (write_byte (file, count) == 0)
+ if (write_byte (file, (unsigned char)count) == 0)
return 0;
- if (fwrite (string, (int) sizeof (char), (int) count, file) != count)
+ if (fwrite (string, sizeof (char), count, file) != count)
return 0;
}
else
@@ -134,7 +134,7 @@ write_counted_string(FILE *file, char *string)
static int
read_byte(FILE *file, unsigned char *bp)
{
- if (fread ((char *) bp, 1, 1, file) != 1)
+ if (fread (bp, 1, 1, file) != 1)
return 0;
return 1;
}
@@ -145,7 +145,7 @@ read_short(FILE *file, unsigned short *shortp)
{
unsigned char file_short[2];
- if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
+ if (fread (file_short, sizeof (file_short), 1, file) != 1)
return 0;
*shortp = file_short[0] * 256 + file_short[1];
return 1;
@@ -163,10 +163,10 @@ read_counted_string(FILE *file, char **stringp)
if (len == 0) {
data = NULL;
} else {
- data = (char *) malloc ((unsigned) len + 1);
+ data = malloc ((size_t) len + 1);
if (!data)
return 0;
- if (fread (data, (int) sizeof (char), (int) len, file) != len) {
+ if (fread (data, sizeof (char), (size_t) len, file) != len) {
free (data);
return 0;
}
@@ -234,8 +234,7 @@ ReadProxyFileEntry(FILE *proxyFile, ProxyFileEntry **pentry)
unsigned char byte;
int i;
- *pentry = entry = (ProxyFileEntry *) malloc (
- sizeof (ProxyFileEntry));
+ *pentry = entry = malloc (sizeof (ProxyFileEntry));
if (!*pentry)
return 0;
@@ -264,8 +263,7 @@ ReadProxyFileEntry(FILE *proxyFile, ProxyFileEntry **pentry)
entry->wm_command = NULL;
else
{
- entry->wm_command = (char **) malloc (entry->wm_command_count *
- sizeof (char *));
+ entry->wm_command = malloc (entry->wm_command_count * sizeof (char *));
if (!entry->wm_command)
goto give_up;
@@ -295,10 +293,10 @@ give_up:
if (entry->wm_command[i])
free (entry->wm_command[i]);
}
- free ((char *) entry->wm_command);
+ free (entry->wm_command);
}
- free ((char *) entry);
+ free (entry);
*pentry = NULL;
return 0;
diff --git a/smproxy.c b/smproxy.c
index 7bb6331..c29c050 100644
--- a/smproxy.c
+++ b/smproxy.c
@@ -290,8 +290,7 @@ FinishSaveYourself(WinInfo *winInfo, Bool has_WM_SAVEYOURSELF)
prop1.type = SmLISTofARRAY8;
prop1.num_vals = winInfo->wm_command_count;
- prop1.vals = (SmPropValue *) malloc (
- winInfo->wm_command_count * sizeof (SmPropValue));
+ prop1.vals = malloc (winInfo->wm_command_count * sizeof (SmPropValue));
if (!prop1.vals)
{
@@ -315,7 +314,7 @@ FinishSaveYourself(WinInfo *winInfo, Bool has_WM_SAVEYOURSELF)
SmcSetProperties (winInfo->smc_conn, 2, props);
- free ((char *) prop1.vals);
+ free (prop1.vals);
/*
* If the client doesn't support WM_SAVE_YOURSELF, we should
@@ -574,7 +573,7 @@ AddNewWindow(Window window)
if (LookupWindow (window, NULL, NULL))
return (NULL);
- newptr = (WinInfo *) malloc (sizeof (WinInfo));
+ newptr = malloc (sizeof (WinInfo));
if (newptr == NULL)
return (NULL);
@@ -932,8 +931,7 @@ ProxySaveYourselfPhase2CB(SmcConn smcConn, SmPointer clientData)
prop1.name = SmRestartCommand;
prop1.type = SmLISTofARRAY8;
- prop1.vals = (SmPropValue *) malloc (
- (Argc + 4) * sizeof (SmPropValue));
+ prop1.vals = malloc ((Argc + 4) * sizeof (SmPropValue));
if (!prop1.vals)
{
@@ -987,7 +985,7 @@ ProxySaveYourselfPhase2CB(SmcConn smcConn, SmPointer clientData)
props[1] = &prop2;
SmcSetProperties (smcConn, 2, props);
- free ((char *) prop1.vals);
+ free (prop1.vals);
free (discardCommand);
finishUp: