#include "messages.h"
#include "bittorrent.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_messages,
- "Messages specific for the message factory");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_messages, "Messages specific for the message factory");
-#define BITS_TO_BYTES(x) ((x / 8) + (x % 8) ? 1 : 0)
+#define BITS_TO_BYTES(x) (((x) / 8 + (x) % 8) ? 1 : 0)
/** @brief Build a new empty message
* @param type type of the message
return task;
}
-msg_task_t task_message_bitfield_new(const char *issuer_host_name, const char *mailbox, int peer_id, char *bitfield,
- int bitfield_size)
+msg_task_t task_message_bitfield_new(const char *issuer_host_name, const char *mailbox, int peer_id,
+ unsigned int bitfield, int bitfield_size)
{
msg_task_t task = task_message_new(MESSAGE_BITFIELD, issuer_host_name, mailbox, peer_id,
task_message_size(MESSAGE_BITFIELD) + BITS_TO_BYTES(bitfield_size));
size = MESSAGE_UNCHOKE_SIZE;
break;
case MESSAGE_INTERESTED:
- size = MESSAGE_INTERESTED_SIZE;
- break;
case MESSAGE_NOTINTERESTED:
size = MESSAGE_INTERESTED_SIZE;
break;
case MESSAGE_CANCEL:
size = MESSAGE_CANCEL_SIZE;
break;
+ default:
+ THROW_IMPOSSIBLE;
}
return size;
}