Fix calls to logwrap

Make sure all the calls to logwrap are consistent with the function's
semantics.

Change-Id: Ib0e2ad5c283cc4bb06c0ef5d6a9a52a5840b3dd2
This commit is contained in:
Rom Lemarchand 2012-12-21 12:41:43 -08:00 committed by Android (Google) Code Review
parent b9dcde7845
commit 5593c856f4
3 changed files with 31 additions and 11 deletions

View file

@ -39,6 +39,7 @@
#include <cutils/properties.h>
#include "Ext4.h"
#include "VoldUtil.h"
#define MKEXT4FS_PATH "/system/bin/make_ext4fs";
@ -69,7 +70,7 @@ int Ext4::doMount(const char *fsPath, const char *mountPoint, bool ro, bool remo
int Ext4::format(const char *fsPath, const char *mountpoint) {
int fd;
const char *args[6];
const char *args[5];
int rc;
args[0] = MKEXT4FS_PATH;
@ -77,8 +78,7 @@ int Ext4::format(const char *fsPath, const char *mountpoint) {
args[2] = "-a";
args[3] = mountpoint;
args[4] = fsPath;
args[5] = NULL;
rc = logwrap(5, args, 1);
rc = logwrap(ARRAY_SIZE(args), args, 1);
if (rc == 0) {
SLOGI("Filesystem (ext4) formatted OK");

14
Fat.cpp
View file

@ -39,6 +39,7 @@
#include <cutils/properties.h>
#include "Fat.h"
#include "VoldUtil.h"
static char FSCK_MSDOS_PATH[] = "/system/bin/fsck_msdos";
static char MKDOSFS_PATH[] = "/system/bin/newfs_msdos";
@ -55,14 +56,13 @@ int Fat::check(const char *fsPath) {
int pass = 1;
int rc = 0;
do {
const char *args[5];
const char *args[4];
args[0] = FSCK_MSDOS_PATH;
args[1] = "-p";
args[2] = "-f";
args[3] = fsPath;
args[4] = NULL;
rc = logwrap(4, args, 1);
rc = logwrap(ARRAY_SIZE(args), args, 1);
switch(rc) {
case 0:
@ -153,7 +153,7 @@ int Fat::doMount(const char *fsPath, const char *mountPoint,
int Fat::format(const char *fsPath, unsigned int numSectors) {
int fd;
const char *args[11];
const char *args[10];
int rc;
args[0] = MKDOSFS_PATH;
@ -171,12 +171,10 @@ int Fat::format(const char *fsPath, unsigned int numSectors) {
args[7] = "-s";
args[8] = size;
args[9] = fsPath;
args[10] = NULL;
rc = logwrap(11, args, 1);
rc = logwrap(ARRAY_SIZE(args), args, 1);
} else {
args[7] = fsPath;
args[8] = NULL;
rc = logwrap(9, args, 1);
rc = logwrap(8, args, 1);
}
if (rc == 0) {

22
VoldUtil.h Normal file
View file

@ -0,0 +1,22 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _VOLDUTIL_H
#define _VOLDUTIL_H
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
#endif