/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to plugins.d/mandos-client.c

  • Committer: Teddy Hogeborn
  • Date: 2015-07-16 23:01:02 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 325.
  • Revision ID: teddy@recompile.se-20150716230102-62u5uwaguiufc6ac
mandos-client: Don't use memset().

* plugins.d/mandos-client.c (start_mandos_communication): Use compound
                                                          literal
                                                          struct
                                                          assignment
                                                          instead of
                                                          memset().

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
#include <stdlib.h>             /* free(), EXIT_SUCCESS, srand(),
47
47
                                   strtof(), abort() */
48
48
#include <stdbool.h>            /* bool, false, true */
49
 
#include <string.h>             /* memset(), strcmp(), strlen(),
50
 
                                   strerror(), asprintf(), strcpy() */
 
49
#include <string.h>             /* strcmp(), strlen(), strerror(),
 
50
                                   asprintf(), strcpy() */
51
51
#include <sys/ioctl.h>          /* ioctl */
52
52
#include <sys/types.h>          /* socket(), inet_pton(), sockaddr,
53
53
                                   sockaddr_in6, PF_INET6,
1130
1130
    goto mandos_end;
1131
1131
  }
1132
1132
  
1133
 
  memset(&to, 0, sizeof(to));
1134
1133
  if(af == AF_INET6){
1135
 
    ((struct sockaddr_in6 *)&to)->sin6_family = (sa_family_t)af;
1136
 
    ret = inet_pton(af, ip, &((struct sockaddr_in6 *)&to)->sin6_addr);
 
1134
    struct sockaddr_in6 *to6 = (struct sockaddr_in6 *)&to;
 
1135
    *to6 = (struct sockaddr_in6){ .sin6_family = (sa_family_t)af };
 
1136
    ret = inet_pton(af, ip, &to6->sin6_addr);
1137
1137
  } else {                      /* IPv4 */
1138
 
    ((struct sockaddr_in *)&to)->sin_family = (sa_family_t)af;
1139
 
    ret = inet_pton(af, ip, &((struct sockaddr_in *)&to)->sin_addr);
 
1138
    struct sockaddr_in *to4 = (struct sockaddr_in *)&to;
 
1139
    *to4 = (struct sockaddr_in){ .sin_family = (sa_family_t)af };
 
1140
    ret = inet_pton(af, ip, &to4->sin_addr);
1140
1141
  }
1141
1142
  if(ret < 0 ){
1142
1143
    int e = errno;