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

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

Issue 1320011: linux: turn on -Wextra (Closed)
Patch Set: fixed Created 10 years, 9 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
« no previous file with comments | « sandbox/linux/suid/linux_util.c ('k') | sandbox/linux/suid/sandbox.c » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "process_util.h" 8 #include "process_util.h"
9 9
10 #include <fcntl.h> 10 #include <fcntl.h>
(...skipping 20 matching lines...) Expand all
31 if (getuid() != statbuf.st_uid) 31 if (getuid() != statbuf.st_uid)
32 return false; 32 return false;
33 33
34 strcat(oom_adj, "/oom_adj"); 34 strcat(oom_adj, "/oom_adj");
35 int fd = open(oom_adj, O_WRONLY); 35 int fd = open(oom_adj, O_WRONLY);
36 if (fd < 0) 36 if (fd < 0)
37 return false; 37 return false;
38 38
39 char buf[3]; // 0 <= |score| <= 15; 39 char buf[3]; // 0 <= |score| <= 15;
40 snprintf(buf, sizeof(buf), "%d", score); 40 snprintf(buf, sizeof(buf), "%d", score);
41 size_t len = strlen(buf); 41 ssize_t len = strlen(buf);
42 42
43 ssize_t bytes_written = write(fd, buf, len); 43 ssize_t bytes_written = write(fd, buf, len);
44 close(fd); 44 close(fd);
45 return (bytes_written == len); 45 return (bytes_written == len);
46 } 46 }
OLDNEW
« no previous file with comments | « sandbox/linux/suid/linux_util.c ('k') | sandbox/linux/suid/sandbox.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698