Skip to content

Commit

Permalink
system/core 64-bit cleanup.
Browse files Browse the repository at this point in the history
This cleans up most of the size-related problems in system/core.
There are still a few changes needed for a clean 64-bit build,
but they look like they might require changes to things like the
fastboot protocol.

Change-Id: I1560425a289fa158e13e2e3173cc3e71976f92c0
  • Loading branch information
enh-google committed Jan 16, 2014
1 parent e847f42 commit ccecf14
Show file tree
Hide file tree
Showing 30 changed files with 57 additions and 64 deletions.
8 changes: 4 additions & 4 deletions adb/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -269,7 +269,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 (;;) {
Expand Down Expand Up @@ -314,7 +314,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)){
Expand Down Expand Up @@ -397,7 +397,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
Expand Down
2 changes: 1 addition & 1 deletion adb/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions adb/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions adb/transport_local.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion adb/usb_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion adb/usb_linux_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion fastbootd/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* SUCH DAMAGE.
*/

#include <inttypes.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
Expand Down Expand Up @@ -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");
Expand Down
5 changes: 3 additions & 2 deletions fastbootd/commands/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include <sys/stat.h>
#include <fcntl.h>
#include <inttypes.h>
#include <sys/mman.h>

#include "flash.h"
Expand Down Expand Up @@ -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);
}
Expand All @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion fastbootd/secure.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions fastbootd/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions fastbootd/transport_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions fastbootd/usb_linux_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion fs_mgr/fs_mgr_verity.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion init/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions init/property_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions libdiskconfig/diskconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion libion/ion_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libmemtrack/memtrack_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion libsparse/output_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define _LARGEFILE64_SOURCE 1

#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion logcat/logcat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion logwrapper/logwrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions toolbox/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ LOCAL_SRC_FILES := \

LOCAL_C_INCLUDES := bionic/libc/bionic

LOCAL_CFLAGS += -Wno-unused-parameter

LOCAL_SHARED_LIBRARIES := \
libcutils \
liblog \
Expand Down
3 changes: 0 additions & 3 deletions toolbox/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion toolbox/getevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit ccecf14

Please sign in to comment.