Skip to content

Mostly creating constants for buffer-sizes #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 61dad0ab9b
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion demos/connection_demo/client_tipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

#define SERVER_TYPE 18888
#define SERVER_INST 17
#define BUF_SIZE 40

void wait_for_server(__u32 name_type, __u32 name_instance, int wait)
{
Expand Down Expand Up @@ -101,7 +102,7 @@ int main(int argc, char *argv[], char *dummy[])
{
int sd;
struct sockaddr_tipc server_addr;
char buf[40];
char buf[BUF_SIZE];

printf("****** TIPC connection demo client started ******\n\n");

Expand Down
3 changes: 2 additions & 1 deletion demos/hello_world/client_tipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

#define SERVER_TYPE 18888
#define SERVER_INST 17
#define BUF_SIZE 40

void wait_for_server(__u32 name_type, __u32 name_instance, int wait)
{
Expand Down Expand Up @@ -100,7 +101,7 @@ int main(int argc, char *argv[], char *dummy[])
{
int sd;
struct sockaddr_tipc server_addr;
char buf[40] = {"Hello World"};
char buf[BUF_SIZE] = {"Hello World"};

printf("****** TIPC client hello world program started ******\n\n");

Expand Down
5 changes: 3 additions & 2 deletions demos/hello_world/server_tipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@

#define SERVER_TYPE 18888
#define SERVER_INST 17
#define BUF_SIZE 40

int main(int argc, char *argv[], char *dummy[])
{
struct sockaddr_tipc server_addr;
struct sockaddr_tipc client_addr;
socklen_t alen = sizeof(client_addr);
int sd;
char inbuf[40];
char outbuf[40] = "Uh ?";
char inbuf[BUF_SIZE];
char outbuf[BUF_SIZE] = "Uh ?";

printf("****** TIPC server hello world program started ******\n\n");

Expand Down
8 changes: 5 additions & 3 deletions demos/inventory_sim/inventory_sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ Examples

#define TIPC_BOGUS_SUBSCR_TYPE TIPC_TOP_SRV
#define TIPC_BOGUS_SUBSCR_INST 0
#define TRANSACTION_CONTENT_SIZE 100
#define NAME_SIZE 30

enum { /* simulation state values */
STORE_OPEN = 0,
Expand All @@ -182,7 +184,7 @@ enum { /* logging task transaction codes */

struct trans_msg { /* logging task message format */
int code; /* transaction type identifier */
char string_area[100]; /* transaction content */
char string_area[TRANSACTION_CONTENT_SIZE]; /* transaction content */
};

/* locals */
Expand Down Expand Up @@ -940,7 +942,7 @@ int simItem(int itemID, int lagTime, int speed)
uint zone;
uint cluster;
uint node;
char itemName[8];
char itemName[NAME_SIZE];
int haveItem;
int res;
int simRes = SIM_ERROR;
Expand Down Expand Up @@ -1134,7 +1136,7 @@ int simCust(int itemID, int lagTime, int waitTime, int speed, int taskID)
uint zone;
uint cluster;
uint node;
char custName[30];
char custName[NAME_SIZE];
int transactionID;
int needItem;
fd_set readFds;
Expand Down
3 changes: 2 additions & 1 deletion demos/multicast_demo/client_tipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <linux/tipc.h>

#define SERVER_TYPE 18888
#define BUF_SIZE 100

void wait_for_server(__u32 name_type, __u32 name_instance, int wait)
{
Expand Down Expand Up @@ -99,7 +100,7 @@ void wait_for_server(__u32 name_type, __u32 name_instance, int wait)
void client_mcast(int sd, int lower, int upper)
{
struct sockaddr_tipc server_addr;
char buf[100];
char buf[BUF_SIZE];

server_addr.family = AF_TIPC;
server_addr.addrtype = TIPC_ADDR_MCAST;
Expand Down
3 changes: 2 additions & 1 deletion demos/multicast_demo/server_tipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@
#include <linux/tipc.h>

#define SERVER_TYPE 18888
#define BUF_SIZE 100

void server_mcast(int lower, int upper)
{
struct sockaddr_tipc server_addr;
struct sockaddr_tipc client_addr;
socklen_t alen = sizeof(struct sockaddr_tipc);
int sd;
char buf[100];
char buf[BUF_SIZE];

server_addr.family = AF_TIPC;
server_addr.addrtype = TIPC_ADDR_NAMESEQ;
Expand Down
14 changes: 8 additions & 6 deletions tipc-config/tipc-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ typedef void (*VOIDFUNCPTR) ();

#define MAX_COMMANDS 8
#define MAX_TLVS_SPACE 33000 /* must be a multiple of 4 bytes */
#define ADDR_AREA 30
#define REPLY_LEN 256
#define ARGS_SIZE 128

/* local variables */

Expand Down Expand Up @@ -144,7 +147,7 @@ static const char *addr2str(__u32 addr)

static const char *for_dest(void)
{
static char addr_area[30];
static char addr_area[ADDR_AREA];

if (dest == own_node())
return "";
Expand All @@ -154,7 +157,7 @@ static const char *for_dest(void)

static const char *for_domain(const char *string, __u32 domain)
{
static char addr_area[30];
static char addr_area[ADDR_AREA];

if (domain == 0)
return "";
Expand Down Expand Up @@ -408,16 +411,15 @@ static int get_genl_family_id(const char* name)
char request[NLA_SIZE(struct nlattr_family_name)];
int request_len = nla_put_string((struct nlattr *)request, CTRL_ATTR_FAMILY_NAME, name);

char reply[256];
int reply_len = sizeof(reply);
char reply[REPLY_LEN];

/*
* Call control service
*/
int len = genetlink_call(GENL_ID_CTRL, CTRL_CMD_GETFAMILY,
0, 0,
request, request_len,
reply, reply_len);
reply, sizeof(reply));

if (len == -1)
return -1;
Expand Down Expand Up @@ -1216,7 +1218,7 @@ static void disable_bearerset(char *args)

struct command {
void (*fcn) (char *args);
char args[128];
char args[ARGS_SIZE];
};

/*
Expand Down
10 changes: 7 additions & 3 deletions tipc-pipe/tipc-pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@

#include <linux/tipc.h>

#define BUF_SIZE 30
#define MAP_EXPECTED_SEQUENCE_NUMBERS 255
#define OPTIONS 100

#define TRACE_ON

#ifdef TRACE_ON
Expand Down Expand Up @@ -118,7 +122,7 @@ static inline void timestamp()
struct timeval tv;
time_t current;
long ms;
char buf[30];
char buf[BUF_SIZE];

gettimeofday(&tv, NULL);
current = tv.tv_sec;
Expand Down Expand Up @@ -201,7 +205,7 @@ int generate_data(int tipc, int data_num)
int check_generated_data(int tipc)
{
/* map of expected sequence numbers for each sender */
int i[255] = { 0, };
int i[MAP_EXPECTED_SEQUENCE_NUMBERS] = { 0, };
ssize_t len;
struct sockaddr_tipc peer;

Expand Down Expand Up @@ -389,7 +393,7 @@ void tipc_addr_set(struct sockaddr_tipc *A, int addr_type, int server_type, int
options[optnum].flag = (int*)p; options[optnum].has_arg = 0; \
options[optnum].val = v; optnum++; } while (0)

static struct option options[100];
static struct option options[OPTIONS];
int optnum;

int options_init()
Expand Down