<commit_before>// for num_spawnds_online()
#include <if/octopus_rpcclient_defs.h>
#include <octopus/getset.h> // for oct_read TODO
#include <octopus/trigger.h> // for NOP_TRIGGER
#include "internal.h"

size_t num_monitors_online(void)
{
    errval_t err;
    struct octopus_rpc_client *r = get_octopus_rpc_client();
    if (r == NULL) {
        return LIB_ERR_NAMESERVICE_NOT_BOUND;
    }

    char* buffer = NULL;
    errval_t error_code;
    octopus_trigger_id_t tid;

    char** names = NULL;
    size_t count = 0;

    static char* spawnds = "r'spawn.[0-9]+' { iref: _ }";
        err = r->vtbl.get_names(r, spawnds, NOP_TRIGGER, &buffer, &tid, &error_code);
    if (err_is_fail(err) || err_is_fail(error_code)) {
        err = err_push(err, SPAWN_ERR_FIND_SPAWNDS);
        goto out;
    }

    err = oct_parse_names(buffer, &names, &count);
    if (err_is_fail(err)) {
        goto out;
    }

out:
    free(buffer);
    oct_free_names(names, count);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "num_spawnds_online");
        return 0;
    }
    return count;
}

<commit_msg>Fixed bogus return value in num_monitors_online() and added warning printf.<commit_after>// for num_spawnds_online()
#include <if/octopus_rpcclient_defs.h>
#include <octopus/getset.h> // for oct_read TODO
#include <octopus/trigger.h> // for NOP_TRIGGER
#include "internal.h"

size_t num_monitors_online(void)
{
    errval_t err;
    struct octopus_rpc_client *r = get_octopus_rpc_client();
    if (r == NULL) {
        debug_printf("do not have connection to octopus, assuming single-core environment\n");
        return 1;
    }

    char* buffer = NULL;
    errval_t error_code;
    octopus_trigger_id_t tid;

    char** names = NULL;
    size_t count = 0;

    static char* spawnds = "r'spawn.[0-9]+' { iref: _ }";
        err = r->vtbl.get_names(r, spawnds, NOP_TRIGGER, &buffer, &tid, &error_code);
    if (err_is_fail(err) || err_is_fail(error_code)) {
        err = err_push(err, SPAWN_ERR_FIND_SPAWNDS);
        goto out;
    }

    err = oct_parse_names(buffer, &names, &count);
    if (err_is_fail(err)) {
        goto out;
    }

out:
    free(buffer);
    oct_free_names(names, count);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "num_spawnds_online");
        return 0;
    }
    return count;
}


{'fraction_non_alphanumeric': 0.12711496746203904, 'fraction_numerical': 0.0039045553145336228, 'mean_word_length': 3.0886524822695036, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '1183884', 'n_tokens_mistral': 920, 'n_tokens_neox': 881, 'n_words': 182}