lib/fs/readlink/areadlink.h: Cosmetic changes

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-11-01 21:25:50 -05:00
committed by Serge Hallyn
parent 32f10c3dec
commit ed569088cc
2 changed files with 11 additions and 10 deletions
+1 -1
View File
@@ -7,4 +7,4 @@
#include "fs/readlink/areadlink.h"
extern inline char *areadlink(const char *path);
extern inline char *areadlink(const char *link);
+10 -9
View File
@@ -19,27 +19,28 @@
ATTR_STRING(1)
inline char *areadlink(const char *path);
inline char *areadlink(const char *link);
// Similar to readlink(2), but allocate and terminate the string.
inline char *
areadlink(const char *filename)
areadlink(const char *link)
{
size_t size = 1024;
while (true) {
int len;
char *buffer = MALLOC(size, char);
if (NULL == buffer) {
int len;
char *buf;
buf = MALLOC(size, char);
if (NULL == buf)
return NULL;
}
len = readlinknul(filename, buffer, size);
len = readlinknul(link, buf, size);
if (len != -1)
return buffer;
return buf;
free(buffer);
free(buf);
if (errno != E2BIG)
return NULL;