Heavy refactoring based on ccpcheck

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO
2018-10-14 07:19:42 +02:00
parent 4f0dda34c2
commit e7d57df751
38 changed files with 149 additions and 444 deletions

View File

@ -123,7 +123,7 @@ static void test_create_id(){
static void test_split(){
unsigned int i;
int result;
char *p, buf[SMALLBUFSIZE];
char buf[SMALLBUFSIZE];
struct test_data_s_s_i test_data_s_s_i[] = {
{ "hello\nworld\n", "world\n", 1 },
@ -135,7 +135,7 @@ static void test_split(){
TEST_HEADER();
for(i=0; i<sizeof(test_data_s_s_i)/sizeof(struct test_data_s_s_i); i++){
p = split(test_data_s_s_i[i].s1, '\n', buf, sizeof(buf)-1, &result);
chat *p = split(test_data_s_s_i[i].s1, '\n', buf, sizeof(buf)-1, &result);
if(p){ ASSERT(strcmp(buf, "hello") == 0 && strcmp(p, test_data_s_s_i[i].s2) == 0 && result == test_data_s_s_i[i].result, test_data_s_s_i[i].s1); }
else { ASSERT(p == NULL && result == test_data_s_s_i[i].result, test_data_s_s_i[i].s1); }
@ -147,7 +147,7 @@ static void test_split(){
static void test_split_str(){
unsigned int i;
char *p, buf[SMALLBUFSIZE];
char buf[SMALLBUFSIZE];
struct test_data_s_s test_data_s_s[] = {
{ "aaaXXbbbXX", "bbbXX" },
@ -159,7 +159,7 @@ static void test_split_str(){
TEST_HEADER();
for(i=0; i<sizeof(test_data_s_s)/sizeof(struct test_data_s_s); i++){
p = split_str(test_data_s_s[i].s, "XX", buf, sizeof(buf)-1);
char *p = split_str(test_data_s_s[i].s, "XX", buf, sizeof(buf)-1);
if(p){ ASSERT(strcmp(buf, "aaa") == 0 && strcmp(test_data_s_s[i].result, p) == 0, test_data_s_s[i].s); }
else { ASSERT(strcmp(buf, "aaa") == 0 && p == NULL, test_data_s_s[i].s); }

View File

@ -44,10 +44,10 @@ void connect_to_smtp_server(char *server, int port, struct data *data){
char port_string[8], buf[MAXBUFSIZE];
struct addrinfo hints, *res;
data->net->socket = -1;
if(data == NULL) return;
data->net->socket = -1;
snprintf(port_string, sizeof(port_string)-1, "%d", port);
memset(&hints, 0, sizeof(hints));
@ -360,7 +360,7 @@ static void test_smtp_commands_period_command_in_its_own_packet(char *server, in
int main(int argc, char **argv){
int c, port=25;
int port=25;
char *server=NULL;
struct data data;
struct net net;
@ -384,9 +384,9 @@ int main(int argc, char **argv){
int option_index = 0;
c = getopt_long(argc, argv, "c:s:p:t:lh?", long_options, &option_index);
int c = getopt_long(argc, argv, "c:s:p:t:lh?", long_options, &option_index);
#else
c = getopt(argc, argv, "c:s:p:t:lh?");
int c = getopt(argc, argv, "c:s:p:t:lh?");
#endif