From d9aae297ca6b9f1ddd08b2db1b9c0e641836baf8 Mon Sep 17 00:00:00 2001 From: DTB Date: Tue, 29 Aug 2023 21:43:28 -0400 Subject: [PATCH] two liner --- libfatstr/libfatstr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libfatstr/libfatstr.c b/libfatstr/libfatstr.c index dc1e58a..453089c 100644 --- a/libfatstr/libfatstr.c +++ b/libfatstr/libfatstr.c @@ -35,10 +35,11 @@ char * FatStr_convert(struct FatStr *p){ char *r; - if((r = malloc(p->s * (sizeof *(p->v)))) == NULL) /* might be buggy */ - return NULL; - strncpy(r, p->v, p->s); - return r; + /* allocation might be wrong */ + return ((r = malloc(p->s * (sizeof *(p->v)))) == NULL) + ? NULL + : strncpy(r, p->v, p->s) + ; } struct FatStr *