diff options
| author | Sreeram Ramachandran <sreeram@google.com> | 2014-07-09 07:39:30 -0700 |
|---|---|---|
| committer | Sreeram Ramachandran <sreeram@google.com> | 2014-07-09 07:39:30 -0700 |
| commit | c7d804c1d22db40ac79fde46a032cd359e975f5b (patch) | |
| tree | 23f36403ff36e19bc8bf3ea8425ea2a5cfdad6da /server/RouteController.cpp | |
| parent | 4acd34a8e95b1191318216ebad409ec5e1b3d5f0 (diff) | |
Cosmetic: Move constants into file scope.
Change-Id: Ic1398a5867693bb8f1e588e727869ec6a4574432
Diffstat (limited to 'server/RouteController.cpp')
| -rw-r--r-- | server/RouteController.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/server/RouteController.cpp b/server/RouteController.cpp index 66041396..d33c47cb 100644 --- a/server/RouteController.cpp +++ b/server/RouteController.cpp @@ -83,6 +83,8 @@ const bool ACTION_DEL = false; const bool MODIFY_NON_UID_BASED_RULES = true; const char* const RT_TABLES_PATH = "/data/misc/net/rt_tables"; +const int RT_TABLES_FLAGS = O_CREAT | O_TRUNC | O_WRONLY | O_NOFOLLOW | O_CLOEXEC; +const mode_t RT_TABLES_MODE = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; // mode 0644, rw-r--r-- // Avoids "non-constant-expression cannot be narrowed from type 'unsigned int' to 'unsigned short'" // warnings when using RTA_LENGTH(x) inside static initializers (even when x is already uint16_t). @@ -144,15 +146,14 @@ void updateTableNamesFile() { addTableName(entry.second, entry.first, &contents); } - mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; // mode 0644, rw-r--r-- - int fd = open(RT_TABLES_PATH, O_CREAT | O_TRUNC | O_WRONLY | O_NOFOLLOW | O_CLOEXEC, mode); + int fd = open(RT_TABLES_PATH, RT_TABLES_FLAGS, RT_TABLES_MODE); if (fd == -1) { ALOGE("failed to create %s (%s)", RT_TABLES_PATH, strerror(errno)); return; } // File creation is affected by umask, so make sure the right mode bits are set. - if (fchmod(fd, mode) == -1) { - ALOGE("failed to chmod %s to mode 0%o (%s)", RT_TABLES_PATH, mode, strerror(errno)); + if (fchmod(fd, RT_TABLES_MODE) == -1) { + ALOGE("failed to set mode 0%o on %s (%s)", RT_TABLES_MODE, RT_TABLES_PATH, strerror(errno)); } ssize_t bytesWritten = write(fd, contents.data(), contents.size()); if (bytesWritten != static_cast<ssize_t>(contents.size())) { |
