<commit_before>/*
 * Bus Context
 */

#include <c-rbtree.h>
#include <c-stdaux.h>
#include <stdlib.h>
#include <sys/auxv.h>
#include <sys/socket.h>
#include "bus/bus.h"
#include "bus/driver.h"
#include "bus/match.h"
#include "bus/name.h"
#include "dbus/address.h"
#include "util/error.h"
#include "util/log.h"
#include "util/user.h"

int bus_init(Bus *bus,
             Log *log,
             const char *machine_id,
             unsigned int max_bytes,
             unsigned int max_fds,
             unsigned int max_matches,
             unsigned int max_objects) {
        unsigned int maxima[] = { max_bytes, max_fds, max_matches, max_objects };
        void *random;
        int r;

        if (strlen(machine_id) + 1 != sizeof(bus->machine_id))
                return error_origin(-EINVAL);

        *bus = (Bus)BUS_NULL(*bus);
        bus->log = log;

        memcpy(bus->machine_id, machine_id, sizeof(bus->machine_id));

        random = (void *)getauxval(AT_RANDOM);
        c_assert(random);
        memcpy(bus->guid, random, sizeof(bus->guid));

        static_assert(_USER_SLOT_N == C_ARRAY_SIZE(maxima),
                      "User accounting slot mismatch");

        r = user_registry_init(&bus->users, log, _USER_SLOT_N, maxima);
        if (r)
                return error_fold(r);

        return 0;
}<commit_msg>bus/bus: fix static_assert() mixed in code<commit_after>/*
 * Bus Context
 */

#include <c-rbtree.h>
#include <c-stdaux.h>
#include <stdlib.h>
#include <sys/auxv.h>
#include <sys/socket.h>
#include "bus/bus.h"
#include "bus/driver.h"
#include "bus/match.h"
#include "bus/name.h"
#include "dbus/address.h"
#include "util/error.h"
#include "util/log.h"
#include "util/user.h"

int bus_init(Bus *bus,
             Log *log,
             const char *machine_id,
             unsigned int max_bytes,
             unsigned int max_fds,
             unsigned int max_matches,
             unsigned int max_objects) {
        unsigned int maxima[] = { max_bytes, max_fds, max_matches, max_objects };
        void *random;
        int r;

        static_assert(_USER_SLOT_N == C_ARRAY_SIZE(maxima),
                      "User accounting slot mismatch");

        if (strlen(machine_id) + 1 != sizeof(bus->machine_id))
                return error_origin(-EINVAL);

        *bus = (Bus)BUS_NULL(*bus);
        bus->log = log;

        memcpy(bus->machine_id, machine_id, sizeof(bus->machine_id));

        random = (void *)getauxval(AT_RANDOM);
        c_assert(random);
        memcpy(bus->guid, random, sizeof(bus->guid));

        r = user_registry_init(&bus->users, log, _USER_SLOT_N, maxima);
        if (r)
                return error_fold(r);

        return 0;
}
{'fraction_non_alphanumeric': 0.1365491651205937, 'fraction_numerical': 0.001484230055658627, 'mean_word_length': 2.3407682775712515, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 27, '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': '2169272', 'n_tokens_mistral': 918, 'n_tokens_neox': 892, 'n_words': 199}