@@ -411,7 +411,7 @@ static int validate_interfaces(void)
411411 if (strcmp (ifdict [i ]-> nsname , "" )) {
412412 struct targs * targs ;
413413
414- targs = ( struct targs * ) malloc (sizeof (struct targs ));
414+ targs = malloc (sizeof (* targs ));
415415 if (!targs )
416416 exit_with_error (errno );
417417
@@ -578,7 +578,7 @@ static void rx_pkt(struct xsk_socket_info *xsk, struct pollfd *fds)
578578 if (!pkt_node_rx )
579579 exit_with_error (errno );
580580
581- pkt_node_rx -> pkt_frame = ( char * ) malloc (PKT_SIZE );
581+ pkt_node_rx -> pkt_frame = malloc (PKT_SIZE );
582582 if (!pkt_node_rx -> pkt_frame )
583583 exit_with_error (errno );
584584
@@ -739,8 +739,8 @@ static void worker_pkt_validate(void)
739739 if (iphdr -> version == IP_PKT_VER && iphdr -> tos == IP_PKT_TOS ) {
740740 payloadseqnum = * ((uint32_t * )(pkt_node_rx_q -> pkt_frame + PKT_HDR_SIZE ));
741741 if (debug_pkt_dump && payloadseqnum != EOT ) {
742- pkt_obj = ( struct pkt_frame * ) malloc (sizeof (struct pkt_frame ));
743- pkt_obj -> payload = ( char * ) malloc (PKT_SIZE );
742+ pkt_obj = malloc (sizeof (* pkt_obj ));
743+ pkt_obj -> payload = malloc (PKT_SIZE );
744744 memcpy (pkt_obj -> payload , pkt_node_rx_q -> pkt_frame , PKT_SIZE );
745745 pkt_buf [payloadseqnum ] = pkt_obj ;
746746 }
@@ -865,7 +865,7 @@ static void *worker_testapp_validate(void *arg)
865865
866866 TAILQ_INIT (& head );
867867 if (debug_pkt_dump ) {
868- pkt_buf = malloc ( sizeof (struct pkt_frame * * ) * num_frames );
868+ pkt_buf = calloc ( num_frames , sizeof (* pkt_buf ) );
869869 if (!pkt_buf )
870870 exit_with_error (errno );
871871 }
@@ -1017,7 +1017,7 @@ int main(int argc, char **argv)
10171017 u16 UDP_DST_PORT = 2020 ;
10181018 u16 UDP_SRC_PORT = 2121 ;
10191019
1020- ifaceconfig = ( struct ifaceconfigobj * ) malloc (sizeof (struct ifaceconfigobj ));
1020+ ifaceconfig = malloc (sizeof (struct ifaceconfigobj ));
10211021 memcpy (ifaceconfig -> dst_mac , MAC1 , ETH_ALEN );
10221022 memcpy (ifaceconfig -> src_mac , MAC2 , ETH_ALEN );
10231023 inet_aton (IP1 , & ifaceconfig -> dst_ip );
@@ -1026,7 +1026,7 @@ int main(int argc, char **argv)
10261026 ifaceconfig -> src_port = UDP_SRC_PORT ;
10271027
10281028 for (int i = 0 ; i < MAX_INTERFACES ; i ++ ) {
1029- ifdict [i ] = ( struct ifobject * ) malloc (sizeof (struct ifobject ));
1029+ ifdict [i ] = malloc (sizeof (struct ifobject ));
10301030 if (!ifdict [i ])
10311031 exit_with_error (errno );
10321032
0 commit comments