am 8940c0a0: am 97373bbc: am 7cd15614: Merge "system/core 64-bit cleanup."

* commit '8940c0a07f8d6682712e2d2ee387e78096602f99':
  system/core 64-bit cleanup.
This commit is contained in:
Elliott Hughes 2014-01-16 22:11:49 +00:00 committed by Android Git Automerger
commit ec9e5891ac
30 changed files with 57 additions and 64 deletions

View File

@ -86,7 +86,7 @@ void restart_tcp_service(int fd, void *cookie)
{
char buf[100];
char value[PROPERTY_VALUE_MAX];
int port = (int)cookie;
int port = (int) (uintptr_t) cookie;
if (port <= 0) {
snprintf(buf, sizeof(buf), "invalid port\n");
@ -256,7 +256,7 @@ static int create_subprocess(const char *cmd, const char *arg0, const char *arg1
#if !ADB_HOST
static void subproc_waiter_service(int fd, void *cookie)
{
pid_t pid = (pid_t)cookie;
pid_t pid = (pid_t) (uintptr_t) cookie;
D("entered. fd=%d of pid=%d\n", fd, pid);
for (;;) {
@ -301,7 +301,7 @@ static int create_subproc_thread(const char *name)
sti = malloc(sizeof(stinfo));
if(sti == 0) fatal("cannot allocate stinfo");
sti->func = subproc_waiter_service;
sti->cookie = (void*)pid;
sti->cookie = (void*) (uintptr_t) pid;
sti->fd = ret_fd;
if(adb_thread_create( &t, service_bootstrap_func, sti)){
@ -384,7 +384,7 @@ int service_to_fd(const char *name)
if (sscanf(name + 6, "%d", &port) == 0) {
port = 0;
}
ret = create_service_thread(restart_tcp_service, (void *)port);
ret = create_service_thread(restart_tcp_service, (void *) (uintptr_t) port);
} else if(!strncmp(name, "usb:", 4)) {
ret = create_service_thread(restart_usb_service, NULL);
#endif

View File

@ -342,7 +342,7 @@ static void local_socket_event_func(int fd, unsigned ev, void *_s)
while(avail > 0) {
r = adb_read(fd, x, avail);
D("LS(%d): post adb_read(fd=%d,...) r=%d (errno=%d) avail=%d\n", s->id, s->fd, r, r<0?errno:0, avail);
D("LS(%d): post adb_read(fd=%d,...) r=%d (errno=%d) avail=%zu\n", s->id, s->fd, r, r<0?errno:0, avail);
if(r > 0) {
avail -= r;
x += r;

View File

@ -1142,9 +1142,9 @@ int readx(int fd, void *ptr, size_t len)
char *p = ptr;
int r;
#if ADB_TRACE
int len0 = len;
size_t len0 = len;
#endif
D("readx: fd=%d wanted=%d\n", fd, (int)len);
D("readx: fd=%d wanted=%zu\n", fd, len);
while(len > 0) {
r = adb_read(fd, p, len);
if(r > 0) {
@ -1163,7 +1163,7 @@ int readx(int fd, void *ptr, size_t len)
}
#if ADB_TRACE
D("readx: fd=%d wanted=%d got=%d\n", fd, len0, len0 - len);
D("readx: fd=%d wanted=%zu got=%zu\n", fd, len0, len0 - len);
dump_hex( ptr, len0 );
#endif
return 0;

View File

@ -159,7 +159,7 @@ static void *server_socket_thread(void * arg)
int serverfd, fd;
struct sockaddr addr;
socklen_t alen;
int port = (int)arg;
int port = (int) (uintptr_t) arg;
D("transport: server_socket_thread() starting\n");
serverfd = -1;
@ -241,7 +241,7 @@ static const char _start_req[] = "start";
/* 'ok' reply from the adb QEMUD service. */
static const char _ok_resp[] = "ok";
const int port = (int)arg;
const int port = (int) (uintptr_t) arg;
int res, fd;
char tmp[256];
char con_name[32];
@ -326,7 +326,7 @@ void local_init(int port)
D("transport: local %s init\n", HOST ? "client" : "server");
if(adb_thread_create(&thr, func, (void *)port)) {
if(adb_thread_create(&thr, func, (void *) (uintptr_t) port)) {
fatal_errno("cannot create local socket %s thread",
HOST ? "client" : "server");
}

View File

@ -179,7 +179,7 @@ static void find_usb_device(const char *base,
// should have device and configuration descriptors, and atleast two endpoints
if (desclength < USB_DT_DEVICE_SIZE + USB_DT_CONFIG_SIZE) {
D("desclength %d is too small\n", desclength);
D("desclength %zu is too small\n", desclength);
adb_close(fd);
continue;
}

View File

@ -384,7 +384,7 @@ static int bulk_read(int bulk_out, char *buf, size_t length)
ret = adb_read(bulk_out, buf + count, length - count);
if (ret < 0) {
if (errno != EINTR) {
D("[ bulk_read failed fd=%d length=%d count=%d ]\n",
D("[ bulk_read failed fd=%d length=%zu count=%zu ]\n",
bulk_out, length, count);
return ret;
}

View File

@ -29,6 +29,7 @@
* SUCH DAMAGE.
*/
#include <inttypes.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
@ -319,7 +320,7 @@ static void cmd_flash(struct protocol_handle *phandle, const char *arg)
return;
}
D(INFO, "writing %lld bytes to '%s'\n", sz, arg);
D(INFO, "writing %"PRId64" bytes to '%s'\n", sz, arg);
if (flash_write(partition, phandle->download_fd, sz, header_sz)) {
fastboot_fail(phandle, "flash write failure");

View File

@ -31,6 +31,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <inttypes.h>
#include <sys/mman.h>
#include "flash.h"
@ -82,7 +83,7 @@ int flash_erase(int fd)
{
int64_t size;
size = get_block_device_size(fd);
D(DEBUG, "erase %llu data from %d\n", size, fd);
D(DEBUG, "erase %"PRId64" data from %d\n", size, fd);
return wipe_block_device(fd, size);
}
@ -97,7 +98,7 @@ int flash_write(int partition_fd, int data_fd, ssize_t size, ssize_t skip)
int current_size = MIN(size - written, BUFFER_SIZE);
if (gpt_mmap(&input, written + skip, current_size, data_fd)) {
D(ERR, "Error in writing data, unable to map data file %d at %d size %d", size, skip, current_size);
D(ERR, "Error in writing data, unable to map data file %zd at %zd size %d", size, skip, current_size);
return -1;
}
if (gpt_mmap(&output, written, current_size, partition_fd)) {

View File

@ -151,7 +151,7 @@ int cert_verify(BIO *content, CMS_ContentInfo *content_info, X509_STORE *store,
char buf[256];
unsigned long err = ERR_peek_last_error();
D(ERR, "Verification failed with reason: %s, %s", ERR_lib_error_string(err), ERR_error_string(err, buf));
D(ERR, "Data used: content %d", (int) content);
D(ERR, "Data used: content %p", content);
}
ERR_clear_error();

View File

@ -56,14 +56,14 @@ int transport_handle_download(struct transport_handle *thandle, size_t len)
buffer = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (buffer == NULL) {
D(ERR, "mmap(%u) failed: %d %s", len, errno, strerror(errno));
D(ERR, "mmap(%zu) failed: %d %s", len, errno, strerror(errno));
goto err;
}
while (n < len) {
ret = thandle->transport->read(thandle, buffer + n, len - n);
if (ret <= 0) {
D(WARN, "transport read failed, ret=%d %s", ret, strerror(-ret));
D(WARN, "transport read failed, ret=%zd %s", ret, strerror(-ret));
break;
}
n += ret;

View File

@ -88,7 +88,7 @@ ssize_t socket_write(struct transport_handle *thandle, const void *data, size_t
ssize_t ret;
struct socket_handle *handle = container_of(thandle, struct socket_handle, handle);
D(DEBUG, "about to write (fd=%d, len=%d)", handle->fd, len);
D(DEBUG, "about to write (fd=%d, len=%zu)", handle->fd, len);
ret = bulk_write(handle->fd, data, len);
if (ret < 0) {
D(ERR, "ERROR: fd = %d, ret = %zd", handle->fd, ret);
@ -103,7 +103,7 @@ ssize_t socket_read(struct transport_handle *thandle, void *data, size_t len)
ssize_t ret;
struct socket_handle *handle = container_of(thandle, struct socket_handle, handle);
D(DEBUG, "about to read (fd=%d, len=%d)", handle->fd, len);
D(DEBUG, "about to read (fd=%d, len=%zu)", handle->fd, len);
ret = bulk_read(handle->fd, data, len);
if (ret < 0) {
D(ERR, "ERROR: fd = %d, ret = %zd", handle->fd, ret);

View File

@ -217,7 +217,7 @@ static ssize_t usb_write(struct transport_handle *thandle, const void *data, siz
struct transport *t = thandle->transport;
struct usb_transport *usb_transport = container_of(t, struct usb_transport, transport);
D(DEBUG, "about to write (fd=%d, len=%d)", usb_transport->bulk_in, len);
D(DEBUG, "about to write (fd=%d, len=%zu)", usb_transport->bulk_in, len);
ret = bulk_write(usb_transport->bulk_in, data, len);
if (ret < 0) {
D(ERR, "ERROR: fd = %d, ret = %zd", usb_transport->bulk_in, ret);
@ -233,7 +233,7 @@ ssize_t usb_read(struct transport_handle *thandle, void *data, size_t len)
struct transport *t = thandle->transport;
struct usb_transport *usb_transport = container_of(t, struct usb_transport, transport);
D(DEBUG, "about to read (fd=%d, len=%d)", usb_transport->bulk_out, len);
D(DEBUG, "about to read (fd=%d, len=%zu)", usb_transport->bulk_out, len);
ret = bulk_read(usb_transport->bulk_out, data, len);
if (ret < 0) {
D(ERR, "ERROR: fd = %d, ret = %zd", usb_transport->bulk_out, ret);

View File

@ -14,6 +14,7 @@
* limitations under the License.
*/
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -178,7 +179,7 @@ static int read_verity_metadata(char *block_device, char **signature, char **tab
goto out;
}
if (magic_number != VERITY_METADATA_MAGIC_NUMBER) {
ERROR("Couldn't find verity metadata at offset %llu!\n", device_length);
ERROR("Couldn't find verity metadata at offset %"PRIu64"!\n", device_length);
goto out;
}

View File

@ -623,7 +623,7 @@ static int mix_hwrng_into_linux_rng_action(int nargs, char **args)
total_bytes_written += chunk_size;
}
INFO("Mixed %d bytes from /dev/hw_random into /dev/urandom",
INFO("Mixed %zu bytes from /dev/hw_random into /dev/urandom",
total_bytes_written);
result = 0;

View File

@ -168,7 +168,7 @@ static int check_mac_perms(const char *name, char *sctx)
if (selabel_lookup(sehandle_prop, &tctx, name, 1) != 0)
goto err;
if (selinux_check_access(sctx, tctx, class, perm, name) == 0)
if (selinux_check_access(sctx, tctx, class, perm, (void*) name) == 0)
result = 1;
freecon(tctx);
@ -382,7 +382,7 @@ void handle_property_set_fd()
r = TEMP_FAILURE_RETRY(recv(s, &msg, sizeof(msg), 0));
if(r != sizeof(prop_msg)) {
ERROR("sys_prop: mis-match msg size received: %d expected: %d errno: %d\n",
ERROR("sys_prop: mis-match msg size received: %d expected: %zu errno: %d\n",
r, sizeof(prop_msg), errno);
close(s);
return;
@ -522,7 +522,7 @@ static void load_persistent_properties()
|| (sb.st_uid != 0)
|| (sb.st_gid != 0)
|| (sb.st_nlink != 1)) {
ERROR("skipping insecure property file %s (uid=%lu gid=%lu nlink=%d mode=%o)\n",
ERROR("skipping insecure property file %s (uid=%u gid=%u nlink=%d mode=%o)\n",
entry->d_name, sb.st_uid, sb.st_gid, sb.st_nlink, sb.st_mode);
close(fd);
continue;

View File

@ -19,6 +19,7 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -80,7 +81,7 @@ parse_len(const char *str, uint64_t *plen)
*plen *= multiple;
if (*plen > 0xffffffffULL) {
ALOGE("Length specified is too large!: %llu KB", *plen);
ALOGE("Length specified is too large!: %"PRIu64" KB", *plen);
return 1;
}
}
@ -371,8 +372,8 @@ validate(struct disk_info *dinfo)
/* only matters for disks, not files */
if (S_ISBLK(stat.st_mode) && total_size > disk_size) {
ALOGE("Total requested size of partitions (%llu) is greater than disk "
"size (%llu).", total_size, disk_size);
ALOGE("Total requested size of partitions (%"PRIu64") is greater than disk "
"size (%"PRIu64").", total_size, disk_size);
goto fail;
}

View File

@ -63,7 +63,7 @@ void ion_alloc_test()
ret = ion_free(fd, handle);
if (ret) {
printf("%s failed: %s %p\n", __func__, strerror(ret), handle);
printf("%s failed: %s %d\n", __func__, strerror(ret), handle);
return;
}
ion_close(fd);

View File

@ -35,7 +35,7 @@ static int getprocname(pid_t pid, char *buf, int len) {
return -1;
}
if (asprintf(&filename, "/proc/%zd/cmdline", pid) < 0) {
if (asprintf(&filename, "/proc/%d/cmdline", pid) < 0) {
rc = 1;
goto exit;
}

View File

@ -18,6 +18,7 @@
#define _LARGEFILE64_SOURCE 1
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
@ -342,7 +343,7 @@ static int write_sparse_skip_chunk(struct output_file *out, int64_t skip_len)
int ret, chunk;
if (skip_len % out->block_size) {
error("don't care size %llu is not a multiple of the block size %u",
error("don't care size %"PRIi64" is not a multiple of the block size %u",
skip_len, out->block_size);
return -1;
}

View File

@ -298,7 +298,7 @@ static void readLogLines(log_device_t* devices)
}
else if (entry->entry.len != ret - sizeof(struct logger_entry)) {
fprintf(stderr, "read: unexpected length. Expected %d, got %d\n",
entry->entry.len, ret - sizeof(struct logger_entry));
entry->entry.len, ret - (int) sizeof(struct logger_entry));
exit(EXIT_FAILURE);
}

View File

@ -90,7 +90,8 @@ int main(int argc, char* argv[]) {
}
if (seg_fault_on_exit) {
*(int *)status = 0; // causes SIGSEGV with fault_address = status
uintptr_t fault_address = (uintptr_t) status;
*(int *) fault_address = 0; // causes SIGSEGV with fault_address = status
}
return rc;

View File

@ -89,6 +89,8 @@ LOCAL_SRC_FILES := \
LOCAL_C_INCLUDES := bionic/libc/bionic
LOCAL_CFLAGS += -Wno-unused-parameter
LOCAL_SHARED_LIBRARIES := \
libcutils \
liblog \

View File

@ -92,9 +92,6 @@ extern u_int files_cnt;
extern int progress;
extern const u_char *ctab;
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define DEFFILEMODE (S_IRUSR | S_IWUSR)
static void dd_close(void);

View File

@ -166,7 +166,7 @@ static int print_possible_events(int fd, int print_flags)
if(bit_labels && (print_flags & PRINT_LABELS)) {
bit_label = get_label(bit_labels, j * 8 + k);
if(bit_label)
printf(" %.20s%c%*s", bit_label, down, 20 - strlen(bit_label), "");
printf(" %.20s%c%*s", bit_label, down, (int) (20 - strlen(bit_label)), "");
else
printf(" %04x%c ", j * 8 + k, down);
} else {

View File

@ -4,6 +4,7 @@
#include <unistd.h>
#include <malloc.h>
#include <errno.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@ -45,7 +46,6 @@ bail:
return buffer;
}
#define min(x,y) ((x) < (y) ? (x) : (y))
int insmod_main(int argc, char **argv)
{
void *file;
@ -73,7 +73,7 @@ int insmod_main(int argc, char **argv)
char *ptr = opts;
for (i = 2; (i < argc) && (ptr < end); i++) {
len = min(strlen(argv[i]), end - ptr);
len = MIN(strlen(argv[i]), end - ptr);
memcpy(ptr, argv[i], len);
ptr += len;
*ptr++ = ' ';

View File

@ -182,8 +182,8 @@ static int listfile_long(const char *path, struct stat *s, int flags)
mode2str(s->st_mode, mode);
if (flags & LIST_LONG_NUMERIC) {
snprintf(user, sizeof(user), "%ld", s->st_uid);
snprintf(group, sizeof(group), "%ld", s->st_gid);
snprintf(user, sizeof(user), "%u", s->st_uid);
snprintf(group, sizeof(group), "%u", s->st_gid);
} else {
user2str(s->st_uid, user, sizeof(user));
group2str(s->st_gid, group, sizeof(group));

View File

@ -158,7 +158,7 @@ int nandread_main(int argc, char **argv)
printf("oobavail: %u\n", ecclayout.oobavail);
}
if (ecclayout.oobavail > spare_size)
printf("oobavail, %d > image spare size, %d\n", ecclayout.oobavail, spare_size);
printf("oobavail, %d > image spare size, %zu\n", ecclayout.oobavail, spare_size);
ret = ioctl(fd, ECCGETSTATS, &initial_ecc);
if (ret) {

View File

@ -234,13 +234,6 @@ static void mklabel(u_int8_t *, const char *);
static void setstr(u_int8_t *, const char *, size_t);
static void usage(void);
#ifdef ANDROID
#define powerof2(x) ((((x) - 1) & (x)) == 0)
#define howmany(x, y) (((x) + ((y) - 1)) / (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
/*
* Construct a FAT12, FAT16, or FAT32 file system.
*/

View File

@ -212,7 +212,7 @@ static void update_table(DIR *d, uint32_t flags)
}
if (!(flags & FLAG_BATCH))
printf("\e[H\e[0J");
printf("Processes: %d, Threads %d\n", processes.active, threads.active);
printf("Processes: %zu, Threads %zu\n", processes.active, threads.active);
switch (time_dp) {
case 3:
printf(" TID --- SINCE LAST ---- ---------- TOTAL ----------\n");

View File

@ -12,12 +12,9 @@
static int activate_thread_switch_vc;
static void *activate_thread(void *arg)
{
int res;
int fd = (int)arg;
int fd = (int) (uintptr_t) arg;
while(activate_thread_switch_vc >= 0) {
do {
res = ioctl(fd, VT_ACTIVATE, (void*)activate_thread_switch_vc);
} while(res < 0 && errno == EINTR);
int res = TEMP_FAILURE_RETRY(ioctl(fd, VT_ACTIVATE, activate_thread_switch_vc));
if (res < 0) {
fprintf(stderr, "ioctl( vcfd, VT_ACTIVATE, vtnum) failed, %d %d %s for %d\n", res, errno, strerror(errno), activate_thread_switch_vc);
}
@ -131,11 +128,9 @@ int setconsole_main(int argc, char *argv[])
activate_thread_switch_vc = switch_vc;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_create(&thread, &attr, activate_thread, (void*)fd);
do {
res = ioctl(fd, VT_WAITACTIVE, (void*)switch_vc);
} while(res < 0 && errno == EINTR);
pthread_create(&thread, &attr, activate_thread, (void*) (uintptr_t) fd);
res = TEMP_FAILURE_RETRY(ioctl(fd, VT_WAITACTIVE, switch_vc));
activate_thread_switch_vc = -1;
if (res < 0) {
fprintf(stderr, "ioctl( vcfd, VT_WAITACTIVE, vtnum) failed, %d %d %s for %d\n", res, errno, strerror(errno), switch_vc);
@ -157,7 +152,7 @@ int setconsole_main(int argc, char *argv[])
}
}
if (mode != -1) {
if (ioctl(fd, KDSETMODE, (void*)mode) < 0) {
if (ioctl(fd, KDSETMODE, mode) < 0) {
fprintf(stderr, "KDSETMODE %d failed\n", mode);
return -1;
}