Merge \"Remove unnecessary ARRAY_SIZE macros.\"

am: c37d8ea22a

Change-Id: Id3443d7247e893ee549ae5b799a8f0bf42088d35
This commit is contained in:
Elliott Hughes 2016-06-29 00:16:44 +00:00 committed by android-build-merger
commit 7191a56e96
5 changed files with 16 additions and 22 deletions

View file

@ -46,8 +46,6 @@
#include "adb_utils.h"
#include "transport.h"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#if !ADB_HOST
#include <cutils/properties.h>
#include <sys/capability.h>

View file

@ -38,8 +38,6 @@
#include <sys/types.h>
#include <unistd.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
#define OP_DOWNLOAD 1
#define OP_COMMAND 2
#define OP_QUERY 3

View file

@ -47,6 +47,7 @@
#include <utility>
#include <vector>
#include <android-base/macros.h>
#include <android-base/parseint.h>
#include <android-base/parsenetaddress.h>
#include <android-base/stringprintf.h>
@ -67,8 +68,6 @@
#define O_BINARY 0
#endif
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a)))
char cur_product[FB_RESPONSE_SZ + 1];
static const char* serial = nullptr;
@ -986,7 +985,7 @@ static void do_update(Transport* transport, const char* filename, const char* sl
setup_requirements(reinterpret_cast<char*>(data), sz);
for (size_t i = 0; i < ARRAY_SIZE(images); ++i) {
for (size_t i = 0; i < arraysize(images); ++i) {
int fd = unzip_to_file(zip, images[i].img_name);
if (fd == -1) {
if (images[i].is_optional) {
@ -1048,7 +1047,7 @@ static void do_flashall(Transport* transport, const char* slot_override, int era
setup_requirements(reinterpret_cast<char*>(data), sz);
for (size_t i = 0; i < ARRAY_SIZE(images); i++) {
for (size_t i = 0; i < arraysize(images); i++) {
fname = find_item(images[i].part_name, product);
fastboot_buffer buf;
if (!load_buf(transport, fname.c_str(), &buf)) {

View file

@ -24,11 +24,12 @@
#include <sstream>
#include <iostream>
#include <android-base/macros.h>
namespace android {
#define STRINGIFY_INNER(x) #x
#define STRINGIFY(x) STRINGIFY_INNER(x)
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
#define ASSERT_OK(x) ASSERT_EQ(0, (x))
#define EXPECT_OK(x) EXPECT_EQ(0, (x))
@ -85,7 +86,7 @@ protected:
}
void ResetValue(unsigned char c = 0xFF) {
for (size_t i = 0; i < ARRAY_SIZE(mValue); ++i) {
for (size_t i = 0; i < arraysize(mValue); ++i) {
mValue[i] = (char) c;
}
}
@ -177,7 +178,7 @@ TEST_F(PropertiesTest, GetBool) {
* TRUE
*/
const char *valuesTrue[] = { "1", "true", "y", "yes", "on", };
for (size_t i = 0; i < ARRAY_SIZE(valuesTrue); ++i) {
for (size_t i = 0; i < arraysize(valuesTrue); ++i) {
ASSERT_OK(property_set(PROPERTY_TEST_KEY, valuesTrue[i]));
bool val = property_get_bool(PROPERTY_TEST_KEY, /*default_value*/false);
EXPECT_TRUE(val) << "Property should've been TRUE for value: '" << valuesTrue[i] << "'";
@ -187,7 +188,7 @@ TEST_F(PropertiesTest, GetBool) {
* FALSE
*/
const char *valuesFalse[] = { "0", "false", "n", "no", "off", };
for (size_t i = 0; i < ARRAY_SIZE(valuesFalse); ++i) {
for (size_t i = 0; i < arraysize(valuesFalse); ++i) {
ASSERT_OK(property_set(PROPERTY_TEST_KEY, valuesFalse[i]));
bool val = property_get_bool(PROPERTY_TEST_KEY, /*default_value*/true);
EXPECT_FALSE(val) << "Property shoud've been FALSE For string value: '" << valuesFalse[i] << "'";
@ -200,7 +201,7 @@ TEST_F(PropertiesTest, GetBool) {
"+1", " 1 ", " true", " true ", " y ", " yes", "yes ",
"+0", "-0", "00", " 00 ", " false", "false ",
};
for (size_t i = 0; i < ARRAY_SIZE(valuesNeither); ++i) {
for (size_t i = 0; i < arraysize(valuesNeither); ++i) {
ASSERT_OK(property_set(PROPERTY_TEST_KEY, valuesNeither[i]));
// The default value should always be used
@ -249,9 +250,9 @@ TEST_F(PropertiesTest, GetInt64) {
DEFAULT_VALUE, DEFAULT_VALUE,
};
ASSERT_EQ(ARRAY_SIZE(setValues), ARRAY_SIZE(getValues));
ASSERT_EQ(arraysize(setValues), arraysize(getValues));
for (size_t i = 0; i < ARRAY_SIZE(setValues); ++i) {
for (size_t i = 0; i < arraysize(setValues); ++i) {
ASSERT_OK(property_set(PROPERTY_TEST_KEY, setValues[i]));
int64_t val = property_get_int64(PROPERTY_TEST_KEY, DEFAULT_VALUE);
@ -296,9 +297,9 @@ TEST_F(PropertiesTest, GetInt32) {
DEFAULT_VALUE, DEFAULT_VALUE,
};
ASSERT_EQ(ARRAY_SIZE(setValues), ARRAY_SIZE(getValues));
ASSERT_EQ(arraysize(setValues), arraysize(getValues));
for (size_t i = 0; i < ARRAY_SIZE(setValues); ++i) {
for (size_t i = 0; i < arraysize(setValues); ++i) {
ASSERT_OK(property_set(PROPERTY_TEST_KEY, setValues[i]));
int32_t val = property_get_int32(PROPERTY_TEST_KEY, DEFAULT_VALUE);

View file

@ -52,8 +52,6 @@ constexpr unsigned int div_round_up(unsigned int x, unsigned int y) {
return (x + y - 1) / y;
}
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
static constexpr size_t kPageSize = 4096;
static constexpr size_t kChunkSize = 256 * 1024;
static constexpr size_t kUsableChunkSize = kChunkSize - kPageSize;
@ -258,7 +256,7 @@ void* Chunk::Alloc() {
unsigned int i = first_free_bitmap_;
while (free_bitmap_[i] == 0)
i++;
assert(i < ARRAY_SIZE(free_bitmap_));
assert(i < arraysize(free_bitmap_));
unsigned int bit = __builtin_ffs(free_bitmap_[i]) - 1;
assert(free_bitmap_[i] & (1U << bit));
free_bitmap_[i] &= ~(1U << bit);
@ -266,7 +264,7 @@ void* Chunk::Alloc() {
assert(n < max_allocations_);
unsigned int page = n * allocation_size_ / kPageSize;
assert(page / 32 < ARRAY_SIZE(dirty_pages_));
assert(page / 32 < arraysize(dirty_pages_));
dirty_pages_[page / 32] |= 1U << (page % 32);
free_count_--;
@ -285,7 +283,7 @@ void Chunk::Free(void* ptr) {
unsigned int i = n / 32;
unsigned int bit = n % 32;
assert(i < ARRAY_SIZE(free_bitmap_));
assert(i < arraysize(free_bitmap_));
assert(!(free_bitmap_[i] & (1U << bit)));
free_bitmap_[i] |= 1U << bit;
free_count_++;