From a781d3a44ea136af4e166e9018644166a9755f54 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 14 Aug 2018 16:12:42 -0400 Subject: Cleanup: fix warning in unix.c The compiler complained about assigning the "const char *" returned by mb_cstring() to a "char *". The warning is correct, as the returned buffer still belongs to the membuffer. The code only worked because destruction of the membuffer was "forgotten". Fix this by using the "detach_buffer()" function, which passes ownership to the caller and accordingly returns a "char *". Signed-off-by: Berthold Stoeger --- core/unix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/unix.c b/core/unix.c index 963d25ac5..a75bcd792 100644 --- a/core/unix.c +++ b/core/unix.c @@ -48,7 +48,8 @@ void subsurface_user_info(struct user_info *user) struct membuffer mb = {}; gethostname(hostname, sizeof(hostname)); put_format(&mb, "%s@%s", username, hostname); - user->email = mb_cstring(&mb); // 'email' is heap allocated + mb_cstring(&mb); + user->email = detach_buffer(&mb); } } -- cgit v1.2.3-70-g09d2