rcuvgd / tmlinux

Automatically exported from code.google.com/p/tmlinux
0 stars 0 forks source link

cil can not translate union initliation into ANSI C 99 correctly #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
cil translates the following union initalization incorrecly. But It have
not raise any error or warning.

in net/ipv4/inet_connection_sock.c
struct dst_entry* inet_csk_route_req(struct sock *sk,
                     const struct request_sock *req)
{
    struct rtable *rt;
    const struct inet_request_sock *ireq = inet_rsk(req);
    struct ip_options *opt = inet_rsk(req)->opt;
#if 0
    struct flowi fl;
    memset(&fl,0,sizeof(fl));

    fl.oif=sk->sk_bound_dev_if;

    fl.nl_u.ip4_u.daddr=((opt && opt->srr) ?  opt->faddr : ireq->rmt_addr);
    fl.nl_u.ip4_u.saddr=ireq->rmt_addr;
    fl.nl_u.ip4_u.tos=RT_CONN_FLAGS(sk); 

    fl.proto=sk->sk_protocol;

    fl.uli_u.ports.sport=inet_sk(sk)->sport;
    fl.uli_u.ports.dport=ireq->rmt_port;
#else
    struct flowi fl = { .oif = sk->sk_bound_dev_if,
                .nl_u = { .ip4_u =
                      { .daddr = ((opt && opt->srr) ?
                          opt->faddr :
                          ireq->rmt_addr),
                    .saddr = ireq->loc_addr,
                    .tos = RT_CONN_FLAGS(sk) } },
                .proto = sk->sk_protocol,
                .uli_u = { .ports =
                       { .sport = inet_sk(sk)->sport,
                     .dport = ireq->rmt_port } } };

#endif 

CIL can not translate struct flowi fl correctly!! which includes several
union type.

Original issue reported on code.google.com by camelguo@gmail.com on 28 Dec 2008 at 7:25

GoogleCodeExporter commented 8 years ago
1. find all union initialization using gcc extension and modify them manually.
2. Make a simple testcases and validate using the newest CIL, if it does a bug,
submit to cil.sourceforget.net.

Original comment by camelguo@gmail.com on 28 Dec 2008 at 8:39

GoogleCodeExporter commented 8 years ago

Original comment by camelguo@gmail.com on 3 Jan 2009 at 9:52