C
creamsoda.c
I am wondering if the following code snippet has an issue, can
somebody tell me if the parameter passed to getPacket() is done the
correct way? I expect packet to be populated with the contents. Is
this valid? I am new to C. For now please assume that the size of the
buffer passed (55) is sufficient.
extern int getPacket(unsigned char* packet);
static bool func1(message* msg)
{
unsigned char *cmd = NULL;
short cmd_len;
unsigned char packet[55];
if (getPacket(packet) == REJECTED)
{
printf("FAIL: getPacket returns REJECTED\n");
return; /* no packet to read */
}
cmd = (unsigned char*) packet;
cmd_len = packet[1];
}
somebody tell me if the parameter passed to getPacket() is done the
correct way? I expect packet to be populated with the contents. Is
this valid? I am new to C. For now please assume that the size of the
buffer passed (55) is sufficient.
extern int getPacket(unsigned char* packet);
static bool func1(message* msg)
{
unsigned char *cmd = NULL;
short cmd_len;
unsigned char packet[55];
if (getPacket(packet) == REJECTED)
{
printf("FAIL: getPacket returns REJECTED\n");
return; /* no packet to read */
}
cmd = (unsigned char*) packet;
cmd_len = packet[1];
}