summaryrefslogtreecommitdiff
path: root/ext4_utils
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-08-05 17:16:22 -0700
committerAndreas Gampe <agampe@google.com>2015-08-12 17:53:41 -0700
commit03439d34f1fa0c597511035279f8d40c32761eb9 (patch)
treea30223dcc0de650a73270be9106e623230289669 /ext4_utils
parent883d7a7d08cae35d8a1479c4d5b40d2d8fa3ff5c (diff)
downloadextras-03439d34f1fa0c597511035279f8d40c32761eb9.tar.gz
Ext4utils: Fix unused parameters
Refactor code so that parameters are not unused and the debug code is always at least checked (and in non-debug cases compiled away). Bug: 18632512 (cherry picked from commit 7ec740fee7356dd72918c9b9fd0a91276356673b) Change-Id: I0e1eedae97a6edceb1771e10e6ec82c641ba9c5e
Diffstat (limited to 'ext4_utils')
-rw-r--r--ext4_utils/canned_fs_config.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/ext4_utils/canned_fs_config.c b/ext4_utils/canned_fs_config.c
index 2165feb2..089a8df7 100644
--- a/ext4_utils/canned_fs_config.c
+++ b/ext4_utils/canned_fs_config.c
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
@@ -80,6 +81,8 @@ int load_canned_fs_config(const char* fn) {
return 0;
}
+static const int kDebugCannedFsConfig = 0;
+
void canned_fs_config(const char* path, int dir, const char* target_out_path,
unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities) {
Path key;
@@ -94,16 +97,20 @@ void canned_fs_config(const char* path, int dir, const char* target_out_path,
*mode = p->mode;
*capabilities = p->capabilities;
-#if 0
- // for debugging, run the built-in fs_config and compare the results.
-
- unsigned c_uid, c_gid, c_mode;
- uint64_t c_capabilities;
- fs_config(path, dir, target_out_path, &c_uid, &c_gid, &c_mode, &c_capabilities);
-
- if (c_uid != *uid) printf("%s uid %d %d\n", path, *uid, c_uid);
- if (c_gid != *gid) printf("%s gid %d %d\n", path, *gid, c_gid);
- if (c_mode != *mode) printf("%s mode 0%o 0%o\n", path, *mode, c_mode);
- if (c_capabilities != *capabilities) printf("%s capabilities %llx %llx\n", path, *capabilities, c_capabilities);
-#endif
+ if (kDebugCannedFsConfig) {
+ // for debugging, run the built-in fs_config and compare the results.
+
+ unsigned c_uid, c_gid, c_mode;
+ uint64_t c_capabilities;
+ fs_config(path, dir, target_out_path, &c_uid, &c_gid, &c_mode, &c_capabilities);
+
+ if (c_uid != *uid) printf("%s uid %d %d\n", path, *uid, c_uid);
+ if (c_gid != *gid) printf("%s gid %d %d\n", path, *gid, c_gid);
+ if (c_mode != *mode) printf("%s mode 0%o 0%o\n", path, *mode, c_mode);
+ if (c_capabilities != *capabilities)
+ printf("%s capabilities %" PRIx64 " %" PRIx64 "\n",
+ path,
+ *capabilities,
+ c_capabilities);
+ }
}