<commit_before>#include "canread.h"
#include "canutil_pic32.h"
#include "signals.h"
#include "log.h"

CanMessage receiveCanMessage(CanBus* bus) {
    CAN::RxMessageBuffer* message = CAN_CONTROLLER(bus)->getRxMessage(
            CAN::CHANNEL1);

    CanMessage result = {message->msgSID.SID, 0};
    result.data = message->data[0];
    result.data |= (((uint64_t)message->data[1]) << 8);
    result.data |= (((uint64_t)message->data[2]) << 16);
    result.data |= (((uint64_t)message->data[3]) << 24);
    result.data |= (((uint64_t)message->data[4]) << 32);
    result.data |= (((uint64_t)message->data[5]) << 40);
    result.data |= (((uint64_t)message->data[6]) << 48);
    result.data |= (((uint64_t)message->data[7]) << 56);
    return result;
}

void handleCanInterrupt(CanBus* bus) {
    if((CAN_CONTROLLER(bus)->getModuleEvent() & CAN::RX_EVENT) != 0) {
        if(CAN_CONTROLLER(bus)->getPendingEventCode() == CAN::CHANNEL1_EVENT) {
            // Clear the event so we give up control of the CPU
            CAN_CONTROLLER(bus)->enableChannelEvent(CAN::CHANNEL1,
                    CAN::RX_CHANNEL_NOT_EMPTY, false);

            CanMessage message = receiveCanMessage(bus);
            if(!QUEUE_PUSH(CanMessage, &bus->receiveQueue, message)) {
                debug("Dropped CAN message with ID 0x%02x -- queue is full\r\n",
                        message.id);
            }

            /* Call the CAN::updateChannel() function to let the CAN module know
             * that the message processing is done. Enable the event so that the
             * CAN module generates an interrupt when the event occurs.*/
            CAN_CONTROLLER(bus)->updateChannel(CAN::CHANNEL1);
            CAN_CONTROLLER(bus)->enableChannelEvent(CAN::CHANNEL1,
                    CAN::RX_CHANNEL_NOT_EMPTY, true);
        }<commit_msg>Combine some if statements to require less indenting.<commit_after>#include "canread.h"
#include "canutil_pic32.h"
#include "signals.h"
#include "log.h"

CanMessage receiveCanMessage(CanBus* bus) {
    CAN::RxMessageBuffer* message = CAN_CONTROLLER(bus)->getRxMessage(
            CAN::CHANNEL1);

    CanMessage result = {message->msgSID.SID, 0};
    result.data = message->data[0];
    result.data |= (((uint64_t)message->data[1]) << 8);
    result.data |= (((uint64_t)message->data[2]) << 16);
    result.data |= (((uint64_t)message->data[3]) << 24);
    result.data |= (((uint64_t)message->data[4]) << 32);
    result.data |= (((uint64_t)message->data[5]) << 40);
    result.data |= (((uint64_t)message->data[6]) << 48);
    result.data |= (((uint64_t)message->data[7]) << 56);
    return result;
}

void handleCanInterrupt(CanBus* bus) {
    if((CAN_CONTROLLER(bus)->getModuleEvent() & CAN::RX_EVENT) != 0
            && CAN_CONTROLLER(bus)->getPendingEventCode()
            == CAN::CHANNEL1_EVENT) {
        // Clear the event so we give up control of the CPU
        CAN_CONTROLLER(bus)->enableChannelEvent(CAN::CHANNEL1,
                CAN::RX_CHANNEL_NOT_EMPTY, false);

        CanMessage message = receiveCanMessage(bus);
        if(!QUEUE_PUSH(CanMessage, &bus->receiveQueue, message)) {
            debug("Dropped CAN message with ID 0x%02x -- queue is full\r\n",
                    message.id);
        }

        /* Call the CAN::updateChannel() function to let the CAN module know
         * that the message processing is done. Enable the event so that the
         * CAN module generates an interrupt when the event occurs.*/
        CAN_CONTROLLER(bus)->updateChannel(CAN::CHANNEL1);
        CAN_CONTROLLER(bus)->enableChannelEvent(CAN::CHANNEL1,
                CAN::RX_CHANNEL_NOT_EMPTY, true);
{'fraction_non_alphanumeric': 0.1510002740476843, 'fraction_numerical': 0.025760482323924364, 'mean_word_length': 3.0286975717439293, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '474601', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1128, 'n_words': 241}