* Use __func__ wherever possible.
This commit is contained in:
parent
29a063f7fd
commit
0518c124e7
36
src/lib-fd.c
36
src/lib-fd.c
@ -97,10 +97,10 @@ static int (*close_orig) (int fd);
|
||||
&& _zz_mustwatch(file)) \
|
||||
{ \
|
||||
if(oflag & O_CREAT) \
|
||||
debug(STR(fn) "(\"%s\", %i, %i) = %i", \
|
||||
file, oflag, mode, ret); \
|
||||
debug("%s(\"%s\", %i, %i) = %i", \
|
||||
__func__, file, oflag, mode, ret); \
|
||||
else \
|
||||
debug(STR(fn) "(\"%s\", %i) = %i", file, oflag, ret); \
|
||||
debug("%s(\"%s\", %i) = %i", __func__, file, oflag, ret); \
|
||||
_zz_register(ret); \
|
||||
} \
|
||||
} while(0)
|
||||
@ -128,7 +128,7 @@ int accept(int sockfd, struct sockaddr *addr, SOCKLEN_T *addrlen)
|
||||
|
||||
if(ret >= 0)
|
||||
{
|
||||
debug("accept(%i, %p, %p) = %i", sockfd, addr, addrlen, ret);
|
||||
debug("%s(%i, %p, %p) = %i", __func__, sockfd, addr, addrlen, ret);
|
||||
_zz_register(ret);
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ int socket(int domain, int type, int protocol)
|
||||
|
||||
if(ret >= 0)
|
||||
{
|
||||
debug("socket(%i, %i, %i) = %i", domain, type, protocol, ret);
|
||||
debug("%s(%i, %i, %i) = %i", __func__, domain, type, protocol, ret);
|
||||
_zz_register(ret);
|
||||
}
|
||||
|
||||
@ -171,14 +171,14 @@ int recvfrom(int s, void *buf, size_t len, int flags,
|
||||
_zz_addpos(s, ret);
|
||||
|
||||
if(ret >= 4)
|
||||
debug("%s(%i, %p, %li) = %i \"%c%c%c%c...", __FUNCTION__, s, buf,
|
||||
debug("%s(%i, %p, %li) = %i \"%c%c%c%c...", __func__, s, buf,
|
||||
(long int)len, ret, b[0], b[1], b[2], b[3]);
|
||||
else
|
||||
debug("%s(%i, %p, %li) = %i \"%c...", __FUNCTION__, s, buf,
|
||||
debug("%s(%i, %p, %li) = %i \"%c...", __func__, s, buf,
|
||||
(long int)len, ret, b[0]);
|
||||
}
|
||||
else
|
||||
debug("%s(%i, %p, %li) = %i", __FUNCTION__, s, buf, (long int)len, ret);
|
||||
debug("%s(%i, %p, %li) = %i", __func__, s, buf, (long int)len, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -216,14 +216,14 @@ ssize_t read(int fd, void *buf, size_t count)
|
||||
_zz_addpos(fd, ret);
|
||||
|
||||
if(ret >= 4)
|
||||
debug("read(%i, %p, %li) = %i \"%c%c%c%c...", fd, buf,
|
||||
debug("%s(%i, %p, %li) = %i \"%c%c%c%c...", __func__, fd, buf,
|
||||
(long int)count, ret, b[0], b[1], b[2], b[3]);
|
||||
else
|
||||
debug("read(%i, %p, %li) = %i \"%c...", fd, buf,
|
||||
debug("%s(%i, %p, %li) = %i \"%c...", __func__, fd, buf,
|
||||
(long int)count, ret, b[0]);
|
||||
}
|
||||
else
|
||||
debug("read(%i, %p, %li) = %i", fd, buf, (long int)count, ret);
|
||||
debug("%s(%i, %p, %li) = %i", __func__, fd, buf, (long int)count, ret);
|
||||
|
||||
offset_check(fd);
|
||||
return ret;
|
||||
@ -238,7 +238,7 @@ ssize_t readv(int fd, const struct iovec *iov, int count)
|
||||
if(!_zz_ready || !_zz_iswatched(fd) || _zz_disabled)
|
||||
return ret;
|
||||
|
||||
debug("readv(%i, %p, %i) = %li", fd, iov, count, (long int)ret);
|
||||
debug("%s(%i, %p, %i) = %li", __func__, fd, iov, count, (long int)ret);
|
||||
|
||||
while(ret > 0)
|
||||
{
|
||||
@ -278,15 +278,15 @@ ssize_t pread(int fd, void *buf, size_t count, off_t offset)
|
||||
_zz_setpos(fd, curoff);
|
||||
|
||||
if(ret >= 4)
|
||||
debug("pread(%i, %p, %li, %li) = %i \"%c%c%c%c...", fd, buf,
|
||||
debug("%s(%i, %p, %li, %li) = %i \"%c%c%c%c...", __func__, fd, buf,
|
||||
(long int)count, (long int)offset, ret,
|
||||
b[0], b[1], b[2], b[3]);
|
||||
else
|
||||
debug("pread(%i, %p, %li, %li) = %i \"%c...", fd, buf,
|
||||
debug("%s(%i, %p, %li, %li) = %i \"%c...", __func__, fd, buf,
|
||||
(long int)count, (long int)offset, ret, b[0]);
|
||||
}
|
||||
else
|
||||
debug("pread(%i, %p, %li, %li) = %i", fd, buf,
|
||||
debug("%s(%i, %p, %li, %li) = %i", __func__, fd, buf,
|
||||
(long int)count, (long int)offset, ret);
|
||||
|
||||
return ret;
|
||||
@ -299,8 +299,8 @@ ssize_t pread(int fd, void *buf, size_t count, off_t offset)
|
||||
ret = ORIG(fn)(fd, offset, whence); \
|
||||
if(!_zz_ready || !_zz_iswatched(fd) || _zz_disabled) \
|
||||
return ret; \
|
||||
debug(STR(fn)"(%i, %lli, %i) = %lli", \
|
||||
fd, (long long int)offset, whence, (long long int)ret); \
|
||||
debug("%s(%i, %lli, %i) = %lli", __func__, fd, \
|
||||
(long long int)offset, whence, (long long int)ret); \
|
||||
if(ret != (off_t)-1) \
|
||||
_zz_setpos(fd, ret); \
|
||||
} while(0)
|
||||
@ -334,7 +334,7 @@ int close(int fd)
|
||||
if(!_zz_ready || !_zz_iswatched(fd) || _zz_disabled)
|
||||
return ret;
|
||||
|
||||
debug("close(%i) = %i", fd, ret);
|
||||
debug("%s(%i) = %i", __func__, fd, ret);
|
||||
_zz_unregister(fd);
|
||||
|
||||
return ret;
|
||||
|
||||
@ -13,9 +13,19 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* preload.h: preloaded library functions
|
||||
* lib-load.h: preloaded library functions
|
||||
*/
|
||||
|
||||
/* The __func__ macro to get the current function name */
|
||||
#if __STDC_VERSION__ < 199901L
|
||||
# if __GNUC__ >= 2
|
||||
# define __func__ __FUNCTION__
|
||||
# else
|
||||
# define __func__ "<?>"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Symbol loading stuff */
|
||||
#define STR(x) #x
|
||||
#define ORIG(x) x##_orig
|
||||
|
||||
|
||||
@ -212,17 +212,17 @@ int nbmaps = 0;
|
||||
_zz_setpos(fd, oldpos); \
|
||||
ret = b; \
|
||||
if(length >= 4) \
|
||||
debug(STR(fn)"(%p, %li, %i, %i, %i, %lli) = %p \"%c%c%c%c...", \
|
||||
start, (long int)length, prot, flags, fd, \
|
||||
debug("%s(%p, %li, %i, %i, %i, %lli) = %p \"%c%c%c%c...", \
|
||||
__func__, start, (long int)length, prot, flags, fd, \
|
||||
(long long int)offset, ret, b[0], b[1], b[2], b[3]); \
|
||||
else \
|
||||
debug(STR(fn)"(%p, %li, %i, %i, %i, %lli) = %p \"%c...", \
|
||||
start, (long int)length, prot, flags, fd, \
|
||||
debug("%s(%p, %li, %i, %i, %i, %lli) = %p \"%c...", \
|
||||
__func__, start, (long int)length, prot, flags, fd, \
|
||||
(long long int)offset, ret, b[0]); \
|
||||
} \
|
||||
else \
|
||||
debug(STR(fn)"(%p, %li, %i, %i, %i, %lli) = %p", \
|
||||
start, (long int)length, prot, flags, fd, \
|
||||
debug("%s(%p, %li, %i, %i, %i, %lli) = %p", \
|
||||
__func__, start, (long int)length, prot, flags, fd, \
|
||||
(long long int)offset, ret); \
|
||||
} while(0)
|
||||
|
||||
@ -254,7 +254,7 @@ int munmap(void *start, size_t length)
|
||||
ret = munmap_orig(maps[i + 1], length);
|
||||
maps[i] = NULL;
|
||||
maps[i + 1] = NULL;
|
||||
debug("munmap(%p, %li) = %i", start, (long int)length, ret);
|
||||
debug("%s(%p, %li) = %i", __func__, start, (long int)length, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -284,17 +284,18 @@ kern_return_t map_fd(int fd, vm_offset_t offset, vm_offset_t *addr,
|
||||
* closed (unlike mmap, which returns a persistent buffer). */
|
||||
|
||||
if(numbytes >= 4)
|
||||
debug("map_fd(%i, %lli, &%p, %i, %lli) = %i \"%c%c%c%c", fd,
|
||||
(long long int)offset, (void *)*addr, (int)find_space,
|
||||
debug("%s(%i, %lli, &%p, %i, %lli) = %i \"%c%c%c%c", __func__,
|
||||
fd, (long long int)offset, (void *)*addr, (int)find_space,
|
||||
(long long int)numbytes, ret, b[0], b[1], b[2], b[3]);
|
||||
else
|
||||
debug("map_fd(%i, %lli, &%p, %i, %lli) = %i \"%c", fd,
|
||||
debug("%s(%i, %lli, &%p, %i, %lli) = %i \"%c", __func__, fd,
|
||||
(long long int)offset, (void *)*addr, (int)find_space,
|
||||
(long long int)numbytes, ret, b[0]);
|
||||
}
|
||||
else
|
||||
debug("map_fd(%i, %lli, &%p, %i, %lli) = %i", fd, (long long int)offset,
|
||||
(void *)*addr, (int)find_space, (long long int)numbytes, ret);
|
||||
debug("%s(%i, %lli, &%p, %i, %lli) = %i", __func__, fd,
|
||||
(long long int)offset, (void *)*addr, (int)find_space,
|
||||
(long long int)numbytes, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ SIG_T signal(int signum, SIG_T handler)
|
||||
|
||||
ret = signal_orig(signum, isfatal(signum) ? SIG_DFL : handler);
|
||||
|
||||
debug("signal(%i, %p) = %p", signum, handler, ret);
|
||||
debug("%s(%i, %p) = %p", __func__, signum, handler, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -118,7 +118,7 @@ int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
|
||||
else
|
||||
ret = sigaction_orig(signum, act, oldact);
|
||||
|
||||
debug("sigaction(%i, %p, %p) = %i", signum, act, oldact, ret);
|
||||
debug("%s(%i, %p, %p) = %i", __func__, signum, act, oldact, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ int (*__srefill_orig) (FILE *fp);
|
||||
{ \
|
||||
int fd = fileno(ret); \
|
||||
_zz_register(fd); \
|
||||
debug(STR(fn) "(\"%s\", \"%s\") = [%i]", path, mode, fd); \
|
||||
debug("%s(\"%s\", \"%s\") = [%i]", __func__, path, mode, fd); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
@ -142,7 +142,8 @@ FILE *freopen(const char *path, const char *mode, FILE *stream)
|
||||
}
|
||||
|
||||
if(disp)
|
||||
debug("freopen(\"%s\", \"%s\", [%i]) = [%i]", path, mode, fd0, fd1);
|
||||
debug("%s(\"%s\", \"%s\", [%i]) = [%i]", __func__,
|
||||
path, mode, fd0, fd1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -180,7 +181,7 @@ FILE *freopen(const char *path, const char *mode, FILE *stream)
|
||||
_zz_disabled = 1; \
|
||||
ret = ORIG(fn)(stream, offset, whence); \
|
||||
_zz_disabled = 0; \
|
||||
debug(STR(fn)"([%i], %lli, %i) = %i", \
|
||||
debug("%s([%i], %lli, %i) = %i", __func__, \
|
||||
fd, (long long int)offset, whence, ret); \
|
||||
FSEEK_FUZZ(fn2) \
|
||||
} while(0)
|
||||
@ -212,7 +213,7 @@ void rewind(FILE *stream)
|
||||
_zz_disabled = 1;
|
||||
rewind_orig(stream);
|
||||
_zz_disabled = 0;
|
||||
debug("rewind([%i])", fd);
|
||||
debug("%s([%i])", __func__, fd);
|
||||
|
||||
#if defined HAVE___SREFILL /* Don't fuzz or seek if we have __srefill() */
|
||||
#else
|
||||
@ -240,8 +241,8 @@ size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
_zz_disabled = 1;
|
||||
ret = fread_orig(ptr, size, nmemb, stream);
|
||||
_zz_disabled = 0;
|
||||
debug("fread(%p, %li, %li, [%i]) = %li",
|
||||
ptr, (long int)size, (long int)nmemb, fd, (long int)ret);
|
||||
debug("%s(%p, %li, %li, [%i]) = %li", __func__, ptr,
|
||||
(long int)size, (long int)nmemb, fd, (long int)ret);
|
||||
|
||||
#if defined HAVE___SREFILL /* Don't fuzz or seek if we have __srefill() */
|
||||
#else
|
||||
@ -287,9 +288,9 @@ size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
_zz_disabled = 0; \
|
||||
FGETC_FUZZ \
|
||||
if(ret >= 0x20 && ret <= 0x7f) \
|
||||
debug(STR(fn)"([%i]) = 0x%02x '%c'", fd, ret, (char)ret); \
|
||||
debug("%s([%i]) = 0x%02x '%c'", __func__, fd, ret, (char)ret); \
|
||||
else \
|
||||
debug(STR(fn)"([%i]) = 0x%02x", fd, ret); \
|
||||
debug("%s([%i]) = 0x%02x", __func__, fd, ret); \
|
||||
} while(0)
|
||||
|
||||
#undef getc /* can be a macro; we don’t want that */
|
||||
@ -361,7 +362,7 @@ char *fgets(char *s, int size, FILE *stream)
|
||||
}
|
||||
#endif
|
||||
|
||||
debug("fgets(%p, %i, [%i]) = %p", s, size, fd, ret);
|
||||
debug("%s(%p, %i, [%i]) = %p", __func__, s, size, fd, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -393,9 +394,9 @@ int ungetc(int c, FILE *stream)
|
||||
#endif
|
||||
|
||||
if(ret >= 0x20 && ret <= 0x7f)
|
||||
debug("ungetc(0x%02x, [%i]) = 0x%02x '%c'", c, fd, ret, ret);
|
||||
debug("%s(0x%02x, [%i]) = 0x%02x '%c'", __func__, c, fd, ret, ret);
|
||||
else
|
||||
debug("ungetc(0x%02x, [%i]) = 0x%02x", c, fd, ret);
|
||||
debug("%s(0x%02x, [%i]) = 0x%02x", __func__, c, fd, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -411,7 +412,7 @@ int fclose(FILE *fp)
|
||||
_zz_disabled = 1;
|
||||
ret = fclose_orig(fp);
|
||||
_zz_disabled = 0;
|
||||
debug("fclose([%i]) = %i", fd, ret);
|
||||
debug("%s([%i]) = %i", __func__, fd, ret);
|
||||
_zz_unregister(fd);
|
||||
|
||||
return ret;
|
||||
@ -465,10 +466,10 @@ int fclose(FILE *fp)
|
||||
} \
|
||||
} \
|
||||
if(need_delim) \
|
||||
debug(STR(fn) "(%p, %p, 0x%02x, [%i]) = %li", \
|
||||
debug("%s(%p, %p, 0x%02x, [%i]) = %li", __func__, \
|
||||
lineptr, n, delim, fd, (long int)ret); \
|
||||
else \
|
||||
debug(STR(fn) "(%p, %p, [%i]) = %li", \
|
||||
debug("%s(%p, %p, [%i]) = %li", __func__, \
|
||||
lineptr, n, fd, (long int)ret); \
|
||||
return ret; \
|
||||
} while(0)
|
||||
@ -544,7 +545,7 @@ char *fgetln(FILE *stream, size_t *len)
|
||||
ret = fuzz->tmp;
|
||||
#endif
|
||||
|
||||
debug("fgetln([%i], &%li) = %p", fd, (long int)*len, ret);
|
||||
debug("%s([%i], &%li) = %p", __func__, fd, (long int)*len, ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@ -574,7 +575,7 @@ int __srefill(FILE *fp)
|
||||
}
|
||||
|
||||
if(!_zz_disabled)
|
||||
debug("__srefill([%i]) = %i", fd, ret);
|
||||
debug("%s([%i]) = %i", __func__, fd, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user