Skip to content

Commit

Permalink
Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF)
Browse files Browse the repository at this point in the history
Change-Id: Ia0476219b71ece949595515ee07ea072ed349d73
  • Loading branch information
Steve Block committed Jan 17, 2012
1 parent 66b6875 commit 9786ec4
Show file tree
Hide file tree
Showing 22 changed files with 140 additions and 131 deletions.
23 changes: 16 additions & 7 deletions include/cutils/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,23 @@ extern "C" {
/*
* Simplified macro to send a debug log message using the current LOG_TAG.
*/
#ifndef ALOGD
#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
// Temporary measure for code still using old LOG macros.
#ifndef LOGD
#define LOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#define ALOGD LOGD
#define LOGD ALOGD
#endif
#endif

#ifndef LOGD_IF
#define LOGD_IF(cond, ...) \
#ifndef ALOGD_IF
#define ALOGD_IF(cond, ...) \
( (CONDITION(cond)) \
? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#define ALOGD_IF LOGD_IF
// Temporary measure for code still using old LOG macros.
#ifndef LOGD_IF
#define LOGD_IF ALOGD_IF
#endif
#endif

/*
Expand Down Expand Up @@ -188,9 +194,12 @@ extern "C" {
* Conditional based on whether the current LOG_TAG is enabled at
* debug priority.
*/
#ifndef IF_ALOGD
#define IF_ALOGD() IF_ALOG(LOG_DEBUG, LOG_TAG)
// Temporary measure for code still using old LOG macros.
#ifndef IF_LOGD
#define IF_LOGD() IF_ALOG(LOG_DEBUG, LOG_TAG)
#define IF_ALOGD IF_LOGD
#define IF_LOGD IF_ALOGD
#endif
#endif

/*
Expand Down
6 changes: 3 additions & 3 deletions libcutils/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ ssize_t bufferWrite(Buffer* buffer, int fd) {
if (bytesWritten >= 0) {
buffer->remaining -= bytesWritten;

LOGD("Buffer bytes written: %d", (int) bytesWritten);
LOGD("Buffer size: %d", (int) buffer->size);
LOGD("Buffer remaining: %d", (int) buffer->remaining);
ALOGD("Buffer bytes written: %d", (int) bytesWritten);
ALOGD("Buffer size: %d", (int) buffer->size);
ALOGD("Buffer remaining: %d", (int) buffer->remaining);

return buffer->remaining;
}
Expand Down
2 changes: 1 addition & 1 deletion libcutils/loghack.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define ALOG(level, ...) \
((void)printf("cutils:" level "/" LOG_TAG ": " __VA_ARGS__))
#define ALOGV(...) ALOG("V", __VA_ARGS__)
#define LOGD(...) ALOG("D", __VA_ARGS__)
#define ALOGD(...) ALOG("D", __VA_ARGS__)
#define LOGI(...) ALOG("I", __VA_ARGS__)
#define LOGW(...) ALOG("W", __VA_ARGS__)
#define LOGE(...) ALOG("E", __VA_ARGS__)
Expand Down
34 changes: 17 additions & 17 deletions libcutils/mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static void peerUnlock(Peer* peer) {

/** Frees a simple, i.e. header-only, outgoing packet. */
static void outgoingPacketFree(OutgoingPacket* packet) {
LOGD("Freeing outgoing packet.");
ALOGD("Freeing outgoing packet.");
free(packet);
}

Expand Down Expand Up @@ -435,7 +435,7 @@ static void peerProxyHandleError(PeerProxy* peerProxy, char* functionName) {
// Log interruptions but otherwise ignore them.
LOGW("%s() interrupted.", functionName);
} else if (errno == EAGAIN) {
LOGD("EWOULDBLOCK");
ALOGD("EWOULDBLOCK");
// Ignore.
} else {
LOGW("Error returned by %s().", functionName);
Expand All @@ -461,7 +461,7 @@ static bool peerProxyWriteFromBuffer(PeerProxy* peerProxy, Buffer* outgoing) {
static void peerProxyWriteBytes(PeerProxy* peerProxy) {
Buffer* buffer = peerProxy->currentPacket->bytes;
if (peerProxyWriteFromBuffer(peerProxy, buffer)) {
LOGD("Bytes written.");
ALOGD("Bytes written.");
peerProxyNextPacket(peerProxy);
}
}
Expand Down Expand Up @@ -527,10 +527,10 @@ static void peerProxyWrite(SelectableFd* fd) {
Buffer* outgoingHeader = &peerProxy->outgoingHeader;
bool headerWritten = bufferWriteComplete(outgoingHeader);
if (!headerWritten) {
LOGD("Writing header...");
ALOGD("Writing header...");
headerWritten = peerProxyWriteFromBuffer(peerProxy, outgoingHeader);
if (headerWritten) {
LOGD("Header written.");
ALOGD("Header written.");
}
}

Expand Down Expand Up @@ -559,7 +559,7 @@ static void peerProxyWrite(SelectableFd* fd) {
* Sets up a peer proxy's fd before we try to select() it.
*/
static void peerProxyBeforeSelect(SelectableFd* fd) {
LOGD("Before select...");
ALOGD("Before select...");

PeerProxy* peerProxy = (PeerProxy*) fd->data;

Expand All @@ -568,7 +568,7 @@ static void peerProxyBeforeSelect(SelectableFd* fd) {
peerUnlock(peerProxy->peer);

if (hasPackets) {
LOGD("Packets found. Setting onWritable().");
ALOGD("Packets found. Setting onWritable().");

fd->onWritable = &peerProxyWrite;
} else {
Expand All @@ -579,9 +579,9 @@ static void peerProxyBeforeSelect(SelectableFd* fd) {

/** Prepare to read bytes from the peer. */
static void peerProxyExpectBytes(PeerProxy* peerProxy, Header* header) {
LOGD("Expecting %d bytes.", header->size);
peerProxy->inputState = READING_BYTES;
ALOGD("Expecting %d bytes.", header->size);

peerProxy->inputState = READING_BYTES;
if (bufferPrepareForRead(peerProxy->inputBuffer, header->size) == -1) {
LOGW("Couldn't allocate memory for incoming data. Size: %u",
(unsigned int) header->size);
Expand Down Expand Up @@ -963,23 +963,23 @@ static bool peerProxyBufferInput(PeerProxy* peerProxy) {
* Reads input from a peer process.
*/
static void peerProxyRead(SelectableFd* fd) {
LOGD("Reading...");
ALOGD("Reading...");
PeerProxy* peerProxy = (PeerProxy*) fd->data;
int state = peerProxy->inputState;
Buffer* in = peerProxy->inputBuffer;
switch (state) {
case READING_HEADER:
if (peerProxyBufferInput(peerProxy)) {
LOGD("Header read.");
ALOGD("Header read.");
// We've read the complete header.
Header* header = (Header*) in->data;
peerProxyHandleHeader(peerProxy, header);
}
break;
case READING_BYTES:
LOGD("Reading bytes...");
ALOGD("Reading bytes...");
if (peerProxyBufferInput(peerProxy)) {
LOGD("Bytes read.");
ALOGD("Bytes read.");
// We have the complete packet. Notify bytes listener.
peerProxy->peer->onBytes(peerProxy->credentials,
in->data, in->size);
Expand Down Expand Up @@ -1030,7 +1030,7 @@ static void masterAcceptConnection(SelectableFd* listenerFd) {
return;
}

LOGD("Accepted connection as fd %d.", socket);
ALOGD("Accepted connection as fd %d.", socket);

// Get credentials.
Credentials credentials;
Expand Down Expand Up @@ -1118,7 +1118,7 @@ static Peer* localPeer;

/** Frees a packet of bytes. */
static void outgoingPacketFreeBytes(OutgoingPacket* packet) {
LOGD("Freeing outgoing packet.");
ALOGD("Freeing outgoing packet.");
bufferFree(packet->bytes);
free(packet);
}
Expand Down Expand Up @@ -1270,7 +1270,7 @@ void masterPeerInitialize(BytesListener* bytesListener,
LOG_ALWAYS_FATAL("bind() error: %s", strerror(errno));
}

LOGD("Listener socket: %d", listenerSocket);
ALOGD("Listener socket: %d", listenerSocket);

// Queue up to 16 connections.
result = listen(listenerSocket, 16);
Expand Down
14 changes: 7 additions & 7 deletions libcutils/selector.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Selector* selectorCreate(void) {
LOG_ALWAYS_FATAL("pipe() error: %s", strerror(errno));
}

LOGD("Wakeup fd: %d", selector->wakeupPipe[0]);
ALOGD("Wakeup fd: %d", selector->wakeupPipe[0]);

SelectableFd* wakeupFd = selectorAdd(selector, selector->wakeupPipe[0]);
if (wakeupFd == NULL) {
Expand Down Expand Up @@ -169,11 +169,11 @@ static void prepareForSelect(Selector* selector) {

bool inSet = false;
if (maybeAdd(selectableFd, selectableFd->onExcept, exceptFds)) {
LOGD("Selecting fd %d for writing...", selectableFd->fd);
ALOGD("Selecting fd %d for writing...", selectableFd->fd);
inSet = true;
}
if (maybeAdd(selectableFd, selectableFd->onReadable, readFds)) {
LOGD("Selecting fd %d for reading...", selectableFd->fd);
ALOGD("Selecting fd %d for reading...", selectableFd->fd);
inSet = true;
}
if (maybeAdd(selectableFd, selectableFd->onWritable, writeFds)) {
Expand All @@ -200,9 +200,9 @@ static void prepareForSelect(Selector* selector) {
*/
static inline void maybeInvoke(SelectableFd* selectableFd,
void (*callback)(SelectableFd*), fd_set* fdSet) {
if (callback != NULL && !selectableFd->remove &&
if (callback != NULL && !selectableFd->remove &&
FD_ISSET(selectableFd->fd, fdSet)) {
LOGD("Selected fd %d.", selectableFd->fd);
ALOGD("Selected fd %d.", selectableFd->fd);
callback(selectableFd);
}
}
Expand Down Expand Up @@ -238,13 +238,13 @@ void selectorLoop(Selector* selector) {

prepareForSelect(selector);

LOGD("Entering select().");
ALOGD("Entering select().");

// Select file descriptors.
int result = select(selector->maxFd + 1, &selector->readFds,
&selector->writeFds, &selector->exceptFds, NULL);

LOGD("Exiting select().");
ALOGD("Exiting select().");

setInSelect(selector, false);

Expand Down
50 changes: 25 additions & 25 deletions libnetutils/dhcpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void printerr(char *fmt, ...)
vsnprintf(errmsg, sizeof(errmsg), fmt, ap);
va_end(ap);

LOGD("%s", errmsg);
ALOGD("%s", errmsg);
}

const char *dhcp_lasterror()
Expand Down Expand Up @@ -151,14 +151,14 @@ static const char *dhcp_type_to_name(uint32_t type)
void dump_dhcp_info(dhcp_info *info)
{
char addr[20], gway[20], mask[20];
LOGD("--- dhcp %s (%d) ---",
ALOGD("--- dhcp %s (%d) ---",
dhcp_type_to_name(info->type), info->type);
strcpy(addr, ipaddr(info->ipaddr));
strcpy(gway, ipaddr(info->gateway));
LOGD("ip %s gw %s prefixLength %d", addr, gway, info->prefixLength);
if (info->dns1) LOGD("dns1: %s", ipaddr(info->dns1));
if (info->dns2) LOGD("dns2: %s", ipaddr(info->dns2));
LOGD("server %s, lease %d seconds",
ALOGD("ip %s gw %s prefixLength %d", addr, gway, info->prefixLength);
if (info->dns1) ALOGD("dns1: %s", ipaddr(info->dns1));
if (info->dns2) ALOGD("dns2: %s", ipaddr(info->dns2));
ALOGD("server %s, lease %d seconds",
ipaddr(info->serveraddr), info->lease);
}

Expand Down Expand Up @@ -250,9 +250,9 @@ void dump_dhcp_msg(dhcp_msg *msg, int len)
const char *name;
char buf[2048];

LOGD("===== DHCP message:");
ALOGD("===== DHCP message:");
if (len < DHCP_MSG_FIXED_SIZE) {
LOGD("Invalid length %d, should be %d", len, DHCP_MSG_FIXED_SIZE);
ALOGD("Invalid length %d, should be %d", len, DHCP_MSG_FIXED_SIZE);
return;
}

Expand All @@ -264,18 +264,18 @@ void dump_dhcp_msg(dhcp_msg *msg, int len)
name = "BOOTREPLY";
else
name = "????";
LOGD("op = %s (%d), htype = %d, hlen = %d, hops = %d",
ALOGD("op = %s (%d), htype = %d, hlen = %d, hops = %d",
name, msg->op, msg->htype, msg->hlen, msg->hops);
LOGD("xid = 0x%08x secs = %d, flags = 0x%04x optlen = %d",
ALOGD("xid = 0x%08x secs = %d, flags = 0x%04x optlen = %d",
ntohl(msg->xid), ntohs(msg->secs), ntohs(msg->flags), len);
LOGD("ciaddr = %s", ipaddr(msg->ciaddr));
LOGD("yiaddr = %s", ipaddr(msg->yiaddr));
LOGD("siaddr = %s", ipaddr(msg->siaddr));
LOGD("giaddr = %s", ipaddr(msg->giaddr));
ALOGD("ciaddr = %s", ipaddr(msg->ciaddr));
ALOGD("yiaddr = %s", ipaddr(msg->yiaddr));
ALOGD("siaddr = %s", ipaddr(msg->siaddr));
ALOGD("giaddr = %s", ipaddr(msg->giaddr));

c = msg->hlen > 16 ? 16 : msg->hlen;
hex2str(buf, msg->chaddr, c);
LOGD("chaddr = {%s}", buf);
ALOGD("chaddr = {%s}", buf);

for (n = 0; n < 64; n++) {
if ((msg->sname[n] < ' ') || (msg->sname[n] > 127)) {
Expand All @@ -293,8 +293,8 @@ void dump_dhcp_msg(dhcp_msg *msg, int len)
}
msg->file[127] = 0;

LOGD("sname = '%s'", msg->sname);
LOGD("file = '%s'", msg->file);
ALOGD("sname = '%s'", msg->sname);
ALOGD("file = '%s'", msg->file);

if (len < 4) return;
len -= 4;
Expand Down Expand Up @@ -327,7 +327,7 @@ void dump_dhcp_msg(dhcp_msg *msg, int len)
name = dhcp_type_to_name(x[2]);
else
name = NULL;
LOGD("op %d len %d {%s} %s", x[0], optsz, buf, name == NULL ? "" : name);
ALOGD("op %d len %d {%s} %s", x[0], optsz, buf, name == NULL ? "" : name);
len -= optsz;
x = x + optsz + 2;
}
Expand All @@ -347,28 +347,28 @@ static int send_message(int sock, int if_index, dhcp_msg *msg, int size)
static int is_valid_reply(dhcp_msg *msg, dhcp_msg *reply, int sz)
{
if (sz < DHCP_MSG_FIXED_SIZE) {
if (verbose) LOGD("netcfg: Wrong size %d != %d\n", sz, DHCP_MSG_FIXED_SIZE);
if (verbose) ALOGD("netcfg: Wrong size %d != %d\n", sz, DHCP_MSG_FIXED_SIZE);
return 0;
}
if (reply->op != OP_BOOTREPLY) {
if (verbose) LOGD("netcfg: Wrong Op %d != %d\n", reply->op, OP_BOOTREPLY);
if (verbose) ALOGD("netcfg: Wrong Op %d != %d\n", reply->op, OP_BOOTREPLY);
return 0;
}
if (reply->xid != msg->xid) {
if (verbose) LOGD("netcfg: Wrong Xid 0x%x != 0x%x\n", ntohl(reply->xid),
if (verbose) ALOGD("netcfg: Wrong Xid 0x%x != 0x%x\n", ntohl(reply->xid),
ntohl(msg->xid));
return 0;
}
if (reply->htype != msg->htype) {
if (verbose) LOGD("netcfg: Wrong Htype %d != %d\n", reply->htype, msg->htype);
if (verbose) ALOGD("netcfg: Wrong Htype %d != %d\n", reply->htype, msg->htype);
return 0;
}
if (reply->hlen != msg->hlen) {
if (verbose) LOGD("netcfg: Wrong Hlen %d != %d\n", reply->hlen, msg->hlen);
if (verbose) ALOGD("netcfg: Wrong Hlen %d != %d\n", reply->hlen, msg->hlen);
return 0;
}
if (memcmp(msg->chaddr, reply->chaddr, msg->hlen)) {
if (verbose) LOGD("netcfg: Wrong chaddr %x != %x\n", *(reply->chaddr),*(msg->chaddr));
if (verbose) ALOGD("netcfg: Wrong chaddr %x != %x\n", *(reply->chaddr),*(msg->chaddr));
return 0;
}
return 1;
Expand Down Expand Up @@ -469,7 +469,7 @@ int dhcp_init_ifc(const char *ifname)
r = receive_packet(s, &reply);
if (r < 0) {
if (errno != 0) {
LOGD("receive_packet failed (%d): %s", r, strerror(errno));
ALOGD("receive_packet failed (%d): %s", r, strerror(errno));
if (errno == ENETDOWN || errno == ENXIO) {
return -1;
}
Expand Down
Loading

0 comments on commit 9786ec4

Please sign in to comment.