Use more generic variable names in read_files()

This commit is contained in:
hasufell 2014-05-10 20:25:24 +02:00
parent 723155a2ce
commit 4bcbb69fc7
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020

View File

@ -68,15 +68,15 @@ char *read_file(char const * const filename)
{ {
char buf[STD_FILE_BUF], char buf[STD_FILE_BUF],
*string = NULL; *string = NULL;
int objfile = 0; int fd = 0;
size_t str_size = 0; size_t str_size = 0;
ssize_t n; ssize_t n;
objfile = open(filename, O_RDONLY); fd = open(filename, O_RDONLY);
if (objfile != -1) { if (fd != -1) {
/* read and copy chunks */ /* read and copy chunks */
while ((n = read(objfile, buf, STD_FILE_BUF)) > 0) { while ((n = read(fd, buf, STD_FILE_BUF)) > 0) {
char *tmp_ptr = NULL; char *tmp_ptr = NULL;
str_size += n; /* count total bytes read */ str_size += n; /* count total bytes read */
@ -94,7 +94,7 @@ char *read_file(char const * const filename)
/* add trailing NULL byte */ /* add trailing NULL byte */
string[str_size] = '\0'; string[str_size] = '\0';
close(objfile); close(fd);
return string; return string;
} else { } else {