atom feed16 messages in org.kernel.vger.kernel-janitors[PATCH 0/9] use correct structure typ...
FromSent OnAttachments
Julia LawallJul 29, 2014 8:16 am 
Julia LawallJul 29, 2014 8:16 am 
Julia LawallJul 29, 2014 8:16 am 
Julia LawallJul 29, 2014 8:16 am 
Julia LawallJul 29, 2014 8:16 am 
Julia LawallJul 29, 2014 8:16 am 
Julia LawallJul 29, 2014 8:16 am 
Julia LawallJul 29, 2014 8:16 am 
Julia LawallJul 29, 2014 8:16 am 
Julia LawallJul 29, 2014 8:16 am 
Brown, Aaron FJul 29, 2014 1:22 pm 
Alexandre CourbotJul 30, 2014 1:27 am 
Julia LawallJul 30, 2014 1:48 am 
David MillerJul 30, 2014 7:14 pm 
David MillerJul 30, 2014 7:14 pm 
Linus WalleijAug 8, 2014 6:26 am 
Subject:[PATCH 0/9] use correct structure type name in sizeof
From:Julia Lawall (Juli@lip6.fr)
Date:Jul 29, 2014 8:16:42 am
List:org.kernel.vger.kernel-janitors

These patches fix typos in the name of a type referenced in a sizeof command. These problems are not caught by the compiler, because they have no impact on execution - the size of a pointer is independent of the size of the pointed value.

The semantic patch that finds these problems is shown below (http://coccinelle.lip6.fr/). This semantic patch distinguishes between structures that are defined in C files, and thus are expected to be visible in only that file, and structures that are defined in header files, which could potential be visible everywhere. This distinction seems to be unnecessary in practice, though.

<smpl> virtual after_start

@initialize:ocaml@ @@

type fl = C of string | H

let structures = Hashtbl.create 101 let restarted = ref false

let add_if_not_present _ = if not !restarted then begin restarted := true; let it = new iteration() in it#add_virtual_rule After_start; it#register() end

let hashadd str file = let cell = try Hashtbl.find structures str with Not_found -> let cell = ref [] in Hashtbl.add structures str cell; cell in if not (List.mem file !cell) then cell := file :: !cell

let get_file fl = if Filename.check_suffix fl ".c" then C fl else H

@script:ocaml depends on !after_start@ @@ add_if_not_present()

@r depends on !after_start@ identifier nm; position p; @@

struct nm@p { ... };

@script:ocaml@ nm << r.nm; p << r.p; @@

hashadd nm (get_file (List.hd p).file)

// -------------------------------------------------------------------------

@sz depends on after_start@ identifier nm; position p; @@

sizeof(struct nm@p *)

@script:ocaml@ nm << sz.nm; p << sz.p; @@

try let allowed = !(Hashtbl.find structures nm) in if List.mem H allowed or List.mem (get_file (List.hd p).file) allowed then () else print_main nm p with Not_found -> print_main nm p </smpl>