diff --git a/DirectVolume.cpp b/DirectVolume.cpp index 02c83d1..0d781d0 100644 --- a/DirectVolume.cpp +++ b/DirectVolume.cpp @@ -189,8 +189,8 @@ void DirectVolume::handlePartitionAdded(const char *devpath, NetlinkEvent *evt) #ifdef PARTITION_DEBUG SLOGD("Dv:partAdd: part_num = %d, minor = %d\n", part_num, minor); #endif - if (part_num >= MAX_PARTITIONS) { - SLOGE("Dv:partAdd: ignoring part_num = %d (max: %d)\n", part_num, MAX_PARTITIONS-1); + if (part_num > MAX_PARTITIONS) { + SLOGE("Dv:partAdd: ignoring part_num = %d (max: %d)\n", part_num, MAX_PARTITIONS); } else { mPartMinors[part_num -1] = minor; } diff --git a/Volume.cpp b/Volume.cpp index 2f3cad5..4ac086b 100644 --- a/Volume.cpp +++ b/Volume.cpp @@ -213,6 +213,7 @@ int Volume::formatVol() { } setState(Volume::State_Formatting); + int ret = -1; if (initializeMbr(devicePath)) { SLOGE("Failed to initialize MBR (%s)", strerror(errno)); goto err; @@ -226,10 +227,11 @@ int Volume::formatVol() { goto err; } - setState(Volume::State_Idle); - return 0; + ret = 0; + err: - return -1; + setState(Volume::State_Idle); + return ret; } bool Volume::isMountpointMounted(const char *path) {