summaryrefslogtreecommitdiffstats
path: root/sandbox/linux
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 00:03:50 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 00:03:50 +0000
commit98254d2e71ed3da0f3b11fce3be11369019488ca (patch)
treeb98ec83822c4f54235ebd6567cadadd56c4cf282 /sandbox/linux
parentde654e242cd46f57c373abe05f058fe094dc6410 (diff)
downloadchromium_src-98254d2e71ed3da0f3b11fce3be11369019488ca.zip
chromium_src-98254d2e71ed3da0f3b11fce3be11369019488ca.tar.gz
chromium_src-98254d2e71ed3da0f3b11fce3be11369019488ca.tar.bz2
linux: turn on -Wextra
This is a followup to an earlier change (r38266) which did most of the warning-related cleanup. This one just flips the flag, and fixes some new warnings that crept in during the window while the flag was off. Second try, now with some libpng fixes. BUG=34160 Review URL: http://codereview.chromium.org/1320011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42700 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox/linux')
-rw-r--r--sandbox/linux/seccomp/library.cc2
-rw-r--r--sandbox/linux/seccomp/library.h2
-rw-r--r--sandbox/linux/seccomp/sandbox_impl.h2
-rw-r--r--sandbox/linux/seccomp/socketcall.cc8
-rw-r--r--sandbox/linux/suid/linux_util.c5
-rw-r--r--sandbox/linux/suid/process_util_linux.c2
-rw-r--r--sandbox/linux/suid/sandbox.c23
7 files changed, 22 insertions, 22 deletions
diff --git a/sandbox/linux/seccomp/library.cc b/sandbox/linux/seccomp/library.cc
index 1b06bc1..768b00a 100644
--- a/sandbox/linux/seccomp/library.cc
+++ b/sandbox/linux/seccomp/library.cc
@@ -318,7 +318,7 @@ const Elf_Shdr* Library::getSection(const string& section) {
return &iter->second.second;
}
-const int Library::getSectionIndex(const string& section) {
+int Library::getSectionIndex(const string& section) {
if (!valid_) {
return -1;
}
diff --git a/sandbox/linux/seccomp/library.h b/sandbox/linux/seccomp/library.h
index 96ec581..e27bfde 100644
--- a/sandbox/linux/seccomp/library.h
+++ b/sandbox/linux/seccomp/library.h
@@ -126,7 +126,7 @@ class Library {
bool parseElf();
const Elf_Ehdr* getEhdr();
const Elf_Shdr* getSection(const string& section);
- const int getSectionIndex(const string& section);
+ int getSectionIndex(const string& section);
void makeWritable(bool state) const;
void patchSystemCalls();
bool isVDSO() const { return isVDSO_; }
diff --git a/sandbox/linux/seccomp/sandbox_impl.h b/sandbox/linux/seccomp/sandbox_impl.h
index 0a98283..18a359c 100644
--- a/sandbox/linux/seccomp/sandbox_impl.h
+++ b/sandbox/linux/seccomp/sandbox_impl.h
@@ -268,7 +268,7 @@ class Sandbox {
// Wrapper around "read()" that can deal with partial and interrupted reads
// and that does not modify the global errno variable.
static ssize_t read(SysCalls& sys, int fd, void* buf, size_t len) {
- if (len < 0) {
+ if (static_cast<ssize_t>(len) < 0) {
sys.my_errno = EINVAL;
return -1;
}
diff --git a/sandbox/linux/seccomp/socketcall.cc b/sandbox/linux/seccomp/socketcall.cc
index 43116bb..497e5e2 100644
--- a/sandbox/linux/seccomp/socketcall.cc
+++ b/sandbox/linux/seccomp/socketcall.cc
@@ -288,8 +288,7 @@ bool Sandbox::process_sendmsg(int parentMapsFd, int sandboxFd, int threadFdPub,
die("Failed to read parameters for sendmsg() [process]");
}
- if (data.msg.msg_namelen < 0 || data.msg.msg_namelen > 4096 ||
- data.msg.msg_controllen < 0 || data.msg.msg_controllen > 4096) {
+ if (data.msg.msg_namelen > 4096 || data.msg.msg_controllen > 4096) {
die("Unexpected size for socketcall() payload [process]");
}
char extra[data.msg.msg_namelen + data.msg.msg_controllen];
@@ -767,7 +766,7 @@ bool Sandbox::process_socketcall(int parentMapsFd, int sandboxFd,
// Verify that the length for the payload is reasonable. We don't want to
// blow up our stack, and excessive (or negative) buffer sizes are almost
// certainly a bug.
- if (numExtraData < 0 || numExtraData > 4096) {
+ if (numExtraData > 4096) {
die("Unexpected size for socketcall() payload [process]");
}
@@ -783,8 +782,7 @@ bool Sandbox::process_socketcall(int parentMapsFd, int sandboxFd,
ssize_t numSendmsgExtra = 0;
if (socketcall_req.call == SYS_SENDMSG) {
struct msghdr* msg = reinterpret_cast<struct msghdr*>(extra);
- if (msg->msg_namelen < 0 || msg->msg_namelen > 4096 ||
- msg->msg_controllen < 0 || msg->msg_controllen > 4096) {
+ if (msg->msg_namelen > 4096 || msg->msg_controllen > 4096) {
die("Unexpected size for socketcall() payload [process]");
}
numSendmsgExtra = msg->msg_namelen + msg->msg_controllen;
diff --git a/sandbox/linux/suid/linux_util.c b/sandbox/linux/suid/linux_util.c
index ded545b..c5af0d0 100644
--- a/sandbox/linux/suid/linux_util.c
+++ b/sandbox/linux/suid/linux_util.c
@@ -83,8 +83,9 @@ bool FindProcessHoldingSocket(pid_t* pid_out, ino_t socket_inode) {
continue;
while ((dent = readdir(fd))) {
- if (snprintf(buf, sizeof(buf), "/proc/%lu/fd/%s", pid_ul,
- dent->d_name) >= sizeof(buf) - 1) {
+ int printed = snprintf(buf, sizeof(buf), "/proc/%lu/fd/%s", pid_ul,
+ dent->d_name);
+ if (printed < 0 || printed >= (int)(sizeof(buf) - 1)) {
continue;
}
diff --git a/sandbox/linux/suid/process_util_linux.c b/sandbox/linux/suid/process_util_linux.c
index 9f40f39..7b31274 100644
--- a/sandbox/linux/suid/process_util_linux.c
+++ b/sandbox/linux/suid/process_util_linux.c
@@ -38,7 +38,7 @@ bool AdjustOOMScore(pid_t process, int score) {
char buf[3]; // 0 <= |score| <= 15;
snprintf(buf, sizeof(buf), "%d", score);
- size_t len = strlen(buf);
+ ssize_t len = strlen(buf);
ssize_t bytes_written = write(fd, buf, len);
close(fd);
diff --git a/sandbox/linux/suid/sandbox.c b/sandbox/linux/suid/sandbox.c
index e4968c9..7389f03 100644
--- a/sandbox/linux/suid/sandbox.c
+++ b/sandbox/linux/suid/sandbox.c
@@ -90,13 +90,13 @@ static int CloneChrootHelperProcess() {
char tempDirectoryTemplate[80] = "/tmp/chrome-sandbox-chroot-XXXXXX";
struct statfs sfs;
if (!statfs("/tmp", &sfs) &&
- sfs.f_type != BTRFS_SUPER_MAGIC &&
- sfs.f_type != EXT2_SUPER_MAGIC &&
- sfs.f_type != EXT3_SUPER_MAGIC &&
- sfs.f_type != EXT4_SUPER_MAGIC &&
- sfs.f_type != REISERFS_SUPER_MAGIC &&
- sfs.f_type != TMPFS_MAGIC &&
- sfs.f_type != XFS_SUPER_MAGIC) {
+ (unsigned long)sfs.f_type != BTRFS_SUPER_MAGIC &&
+ (unsigned long)sfs.f_type != EXT2_SUPER_MAGIC &&
+ (unsigned long)sfs.f_type != EXT3_SUPER_MAGIC &&
+ (unsigned long)sfs.f_type != EXT4_SUPER_MAGIC &&
+ (unsigned long)sfs.f_type != REISERFS_SUPER_MAGIC &&
+ (unsigned long)sfs.f_type != TMPFS_MAGIC &&
+ (unsigned long)sfs.f_type != XFS_SUPER_MAGIC) {
// If /dev/shm exists, it is supposed to be a tmpfs filesystem. While we
// are not actually using it for shared memory, moving our temp directory
// into a known tmpfs filesystem is preferable over using a potentially
@@ -137,7 +137,7 @@ static int CloneChrootHelperProcess() {
char proc_self_fd_str[128];
int printed = snprintf(proc_self_fd_str, sizeof(proc_self_fd_str),
"/proc/self/fd/%d", chroot_dir_fd);
- if (printed < 0 || printed >= sizeof(proc_self_fd_str)) {
+ if (printed < 0 || printed >= (int)sizeof(proc_self_fd_str)) {
fprintf(stderr, "Error in snprintf");
return -1;
}
@@ -246,7 +246,7 @@ static bool SpawnChrootHelper() {
// number of the file descriptor.
char desc_str[64];
int printed = snprintf(desc_str, sizeof(desc_str), "%d", chroot_signal_fd);
- if (printed < 0 || printed >= sizeof(desc_str)) {
+ if (printed < 0 || printed >= (int)sizeof(desc_str)) {
fprintf(stderr, "Failed to snprintf\n");
return false;
}
@@ -379,9 +379,10 @@ int main(int argc, char **argv) {
if (argc == 4 && (0 == strcmp(argv[1], kAdjustOOMScoreSwitch))) {
char* endptr;
long score;
- pid_t pid = strtoul(argv[2], &endptr, 10);
- if (pid == ULONG_MAX || *endptr)
+ unsigned long pid_ul = strtoul(argv[2], &endptr, 10);
+ if (pid_ul == ULONG_MAX || *endptr)
return 1;
+ pid_t pid = pid_ul;
score = strtol(argv[3], &endptr, 10);
if (score == LONG_MAX || score == LONG_MIN || *endptr)
return 1;