[darwinbuild-changes] [85] trunk/darwintrace/darwintrace.c
source_changes at macosforge.org
source_changes at macosforge.org
Wed Oct 4 01:43:46 PDT 2006
Revision: 85
http://trac.macosforge.org/projects/darwinbuild/changeset/85
Author: kevin
Date: 2006-10-04 01:43:46 -0700 (Wed, 04 Oct 2006)
Log Message:
-----------
- fixed warnings since DarwinPorts builds with -Wall (pguyot)
Modified Paths:
--------------
trunk/darwintrace/darwintrace.c
Modified: trunk/darwintrace/darwintrace.c
===================================================================
--- trunk/darwintrace/darwintrace.c 2005-07-21 18:38:01 UTC (rev 84)
+++ trunk/darwintrace/darwintrace.c 2006-10-04 08:43:46 UTC (rev 85)
@@ -35,6 +35,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/param.h>
@@ -55,7 +56,7 @@
__darwintrace_fd = open(path,
O_CREAT | O_WRONLY | O_APPEND,
0666);
- fcntl(__darwintrace_fd, F_SETFD, 1); // close-on-exec
+ fcntl(__darwintrace_fd, F_SETFD, 1); /* close-on-exec */
}
}
#if DARWINTRACE_SHOW_PROCESS
@@ -69,12 +70,13 @@
#endif
}
-// Log calls to open(2) into the file specified by DARWINTRACE_LOG.
-// Only logs if the DARWINTRACE_LOG environment variable is set.
-// Only logs files where the open succeeds.
-// Only logs files opened for read access, without the O_CREAT flag set.
-// The assumption is that any file that can be created isn't necessary
-// to build the project.
+/* Log calls to open(2) into the file specified by DARWINTRACE_LOG.
+ Only logs if the DARWINTRACE_LOG environment variable is set.
+ Only logs files where the open succeeds.
+ Only logs files opened for read access, without the O_CREAT flag set.
+ The assumption is that any file that can be created isn't necessary
+ to build the project.
+*/
int open(const char* path, int flags, ...) {
#define open(x,y,z) syscall(SYS_open, (x), (y), (z))
@@ -95,12 +97,12 @@
if(0 == fcntl(result, F_GETPATH, realpath)) {
#if DARWINTRACE_SHOW_PROCESS
size = snprintf(__darwintrace_buf, BUFFER_SIZE, "%s[%d]\topen\t%s\n", __darwintrace_progname, __darwintrace_pid, realpath );
- // printf("resolved %s to %s\n", path, realpath);
+ /* printf("resolved %s to %s\n", path, realpath); */
#else
size = snprintf(__darwintrace_buf, BUFFER_SIZE, "open\t%s\n", realpath );
#endif
}
- // if we can't resolve it, ignore the volfs path
+ /* if we can't resolve it, ignore the volfs path */
} else {
#if DARWINTRACE_SHOW_PROCESS
size = snprintf(__darwintrace_buf, BUFFER_SIZE, "%s[%d]\topen\t%s\n", __darwintrace_progname, __darwintrace_pid, path );
@@ -118,7 +120,7 @@
int execve(const char* path, char* const argv[], char* const envp[]) {
#define execve(x,y,z) syscall(SYS_execve, (x), (y), (z))
int result;
-
+
__darwintrace_setup();
if (__darwintrace_fd >= 0) {
struct stat sb;
@@ -128,31 +130,33 @@
#else
int size = snprintf(__darwintrace_buf, BUFFER_SIZE, "execve\t%s\n", path );
#endif
+ int fd;
+
write(__darwintrace_fd, __darwintrace_buf, size);
fsync(__darwintrace_fd);
- int fd = open(path, O_RDONLY, 0);
+ fd = open(path, O_RDONLY, 0);
if (fd != -1) {
char buffer[MAXPATHLEN];
ssize_t bytes_read = read(fd, buffer, MAXPATHLEN);
if (buffer[0] == '#' && buffer[1] == '!') {
const char* interp = &buffer[2];
int i;
- // skip past leading whitespace
+ /* skip past leading whitespace */
for (i = 2; i < (MAXPATHLEN-1); ++i) {
if (buffer[i] != ' ' && buffer[i] != '\t') {
interp = &buffer[i];
break;
}
}
- // found interpreter (or ran out of data)
- // skip until next whitespace, then terminate the string
+ /* found interpreter (or ran out of data)
+ skip until next whitespace, then terminate the string */
for (; i < (MAXPATHLEN-1); ++i) {
if (buffer[i] == ' ' || buffer[i] == '\t' || buffer[i] == '\n') {
buffer[i] = 0;
}
}
- // we have liftoff
+ /* we have liftoff */
if (interp) {
#if DARWINTRACE_SHOW_PROCESS
const char* procname = strrchr(argv[0], '/') + 1;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20061004/edda6298/attachment-0001.html
More information about the darwinbuild-changes
mailing list