Wed Sep 21 14:30:48 2011 UTC ()
PR/45383: Henning Petersen: Swapped lseek args


(christos)
diff -r1.23 -r1.24 src/usr.bin/make/meta.c

cvs diff -r1.23 -r1.24 src/usr.bin/make/meta.c (expand / switch to unified diff)

--- src/usr.bin/make/meta.c 2011/09/02 16:26:21 1.23
+++ src/usr.bin/make/meta.c 2011/09/21 14:30:47 1.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: meta.c,v 1.23 2011/09/02 16:26:21 sjg Exp $ */ 1/* $NetBSD: meta.c,v 1.24 2011/09/21 14:30:47 christos Exp $ */
2 2
3/* 3/*
4 * Implement 'meta' mode. 4 * Implement 'meta' mode.
5 * Adapted from John Birrell's patches to FreeBSD make. 5 * Adapted from John Birrell's patches to FreeBSD make.
6 * --sjg 6 * --sjg
7 */ 7 */
8/* 8/*
9 * Copyright (c) 2009-2010, Juniper Networks, Inc. 9 * Copyright (c) 2009-2010, Juniper Networks, Inc.
10 * Portions Copyright (c) 2009, John Birrell. 10 * Portions Copyright (c) 2009, John Birrell.
11 *  11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions  13 * modification, are permitted provided that the following conditions
14 * are met:  14 * are met:
@@ -149,27 +149,27 @@ filemon_open(BuildMon *pbm) @@ -149,27 +149,27 @@ filemon_open(BuildMon *pbm)
149static void 149static void
150filemon_read(FILE *mfp, int fd) 150filemon_read(FILE *mfp, int fd)
151{ 151{
152 FILE *fp; 152 FILE *fp;
153 char buf[BUFSIZ]; 153 char buf[BUFSIZ];
154 154
155 /* Check if we're not writing to a meta data file.*/ 155 /* Check if we're not writing to a meta data file.*/
156 if (mfp == NULL) { 156 if (mfp == NULL) {
157 if (fd >= 0) 157 if (fd >= 0)
158 close(fd); /* not interested */ 158 close(fd); /* not interested */
159 return; 159 return;
160 } 160 }
161 /* rewind */ 161 /* rewind */
162 lseek(fd, SEEK_SET, 0); 162 (void)lseek(fd, (off_t)0, SEEK_SET);
163 if ((fp = fdopen(fd, "r")) == NULL) 163 if ((fp = fdopen(fd, "r")) == NULL)
164 err(1, "Could not read build monitor file '%d'", fd); 164 err(1, "Could not read build monitor file '%d'", fd);
165 165
166 fprintf(mfp, "-- filemon acquired metadata --\n"); 166 fprintf(mfp, "-- filemon acquired metadata --\n");
167 167
168 while (fgets(buf, sizeof(buf), fp)) { 168 while (fgets(buf, sizeof(buf), fp)) {
169 fprintf(mfp, "%s", buf); 169 fprintf(mfp, "%s", buf);
170 } 170 }
171 fflush(mfp); 171 fflush(mfp);
172 clearerr(fp); 172 clearerr(fp);
173 fclose(fp); 173 fclose(fp);
174} 174}
175#endif 175#endif