From 365a94b62df6144ad016e587f3756d974b6e2018 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 30 Dec 2023 20:49:48 +0100 Subject: Add explicit cast after memory allocation Still valid c, but now also valid c++. Signed-off-by: Tim Wiederhake --- src/session.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/session.c') diff --git a/src/session.c b/src/session.c index 77e0d3a..92b25bb 100644 --- a/src/session.c +++ b/src/session.c @@ -216,7 +216,7 @@ read_counted_string(FILE *file, char **stringp) data = 0; } else { - data = malloc((unsigned) len + 1); + data = (char *) malloc((unsigned) len + 1); if (!data) return 0; if (fread(data, (int) sizeof(char), (int) len, file) != len) { @@ -368,7 +368,7 @@ ReadWinConfigEntry(FILE *configFile, unsigned short version, unsigned char byte; int i; - *pentry = entry = malloc(sizeof(TWMWinConfigEntry)); + *pentry = entry = (TWMWinConfigEntry *) malloc(sizeof(TWMWinConfigEntry)); if (!*pentry) return 0; @@ -402,8 +402,8 @@ ReadWinConfigEntry(FILE *configFile, unsigned short version, if (entry->wm_command_count == 0) entry->wm_command = NULL; else { - entry->wm_command = malloc((size_t) entry->wm_command_count * - sizeof(char *)); + entry->wm_command = (char **) + malloc((size_t) entry->wm_command_count * sizeof(char *)); if (!entry->wm_command) goto give_up; @@ -773,7 +773,8 @@ SaveYourselfPhase2CB(SmcConn smcConn2, SmPointer clientData _X_UNUSED) prop1.name = strdup(SmRestartCommand); prop1.type = strdup(SmLISTofARRAY8); - prop1.vals = malloc((size_t) (Argc + 4) * sizeof(SmPropValue)); + prop1.vals = (SmPropValue *) + malloc((size_t) (Argc + 4) * sizeof(SmPropValue)); if (!prop1.vals) { success = False; -- cgit v1.2.3