Hi…I have been trying to use the list implementation in riot os.
#include "wot_list.h"
#include <stdlib.h>
#include <stdio.h>
#include "kernel_defines.h"
static list_node_t head = { .next = NULL };
wot_cert_t *wot_cert_add(char *name, int name_len, uint8_t *pubkey)
{
wot_cert_t *node = calloc(1, sizeof(wot_cert_t));
memcpy(&node->name, name, name_len);
memcpy(&node->pubkey, pubkey, PUB_KEY_SIZE);
list_add(&head, &node->next);
return node;
}
wot_cert_t *wot_cert_find(list_node_t *head, char *name)
{
for (list_node_t *n = head->next; n; n = n->next) {
wot_cert_t *node = container_of(n, wot_cert_t, next);
if (strncmp(node->name, name, sizeof(node->name)) == 0) {
return node;
}
}
return NULL;
}
and the wot_cert_t structure has the following format.
typedef struct {
list_node_t next;
char name[COMMON_NAME_MAX_LEN];
uint8_t pubkey[PUB_KEY_SIZE];
}wot_cert_t;
using the function wot_cert_add, I am adding a new node to the list.But this operation somehow affects the ifconfig command in riot os. before calling the wot_cert_add function, ifconfig gives the following output.
> ifconfig
ifconfig
Iface 7 HWaddr: CE:1B:08:51:92:1A
L2-PDU:1500 MTU:1500 HL:64 Source address length: 6
Link type: wired
inet6 addr: fe80::cc1b:8ff:fe51:921a scope: link VAL
inet6 group: ff02::1
inet6 group: ff02::1:ff51:921a
after adding node in list,for eg. a node with name “alice123”, ifconfig gives the following output.
> ifconfig
ifconfig
Iface 7 HWaddr: CE:1B:08:51:92:1A
L2-PDU:1500 MTU:1500 HL:64 Source address length: 6
Link type: wired
inet6 addr: fe80::cc1b:8ff:fe51:921a scope: link VAL
inet6 group: ff02::1
inet6 group: ff02::1:ff51:921a
alice123s -h
I have not touched the working of ifconfig command, and the last field if the command shows the name of a node,I have added in the list with some garbage.why does this happen ?
Could someone help me to resolve this issue ?