Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: sandbox/linux/suid/process_util_linux.c

Issue 266913019: Ensure that _GNU_SOURCE is defined early enough (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add a better comment Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sandbox/linux/suid/linux_util.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // The following is the C version of code from base/process_utils_linux.cc. 5 // The following is the C version of code from base/process_utils_linux.cc.
6 // We shouldn't link against C++ code in a setuid binary. 6 // We shouldn't link against C++ code in a setuid binary.
7 7
8 // Needed for O_DIRECTORY, must be defined before fcntl.h is included
9 // (and it can be included earlier than the explicit #include below
10 // in some versions of glibc).
11 #define _GNU_SOURCE
12
8 #include "sandbox/linux/suid/process_util.h" 13 #include "sandbox/linux/suid/process_util.h"
9 14
10 #define _GNU_SOURCE // needed for O_DIRECTORY
11
12 #include <fcntl.h> 15 #include <fcntl.h>
13 #include <inttypes.h> 16 #include <inttypes.h>
14 #include <limits.h> 17 #include <limits.h>
15 #include <stdio.h> 18 #include <stdio.h>
16 #include <stdlib.h> 19 #include <stdlib.h>
17 #include <string.h> 20 #include <string.h>
18 #include <sys/stat.h> 21 #include <sys/stat.h>
19 #include <sys/types.h> 22 #include <sys/types.h>
20 #include <unistd.h> 23 #include <unistd.h>
21 24
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 close(dirfd); 69 close(dirfd);
67 70
68 char buf[11]; // 0 <= |score| <= kMaxOomScore; using log_10(2**32) + 1 size 71 char buf[11]; // 0 <= |score| <= kMaxOomScore; using log_10(2**32) + 1 size
69 snprintf(buf, sizeof(buf), "%d", score); 72 snprintf(buf, sizeof(buf), "%d", score);
70 size_t len = strlen(buf); 73 size_t len = strlen(buf);
71 74
72 ssize_t bytes_written = write(fd, buf, len); 75 ssize_t bytes_written = write(fd, buf, len);
73 close(fd); 76 close(fd);
74 return (bytes_written == len); 77 return (bytes_written == len);
75 } 78 }
OLDNEW
« no previous file with comments | « sandbox/linux/suid/linux_util.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698