The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/tools/cocci/zalloc-nofail.cocci

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 // To apply, at the top of xnu.git:
    2 // $ spatch --max-width=80 --use-gitgrep --in-place --include-headers --sp-file tools/cocci/zalloc.cocci -dir .
    3 //
    4 // This might need to be run several times
    5 
    6 @ using "zalloc.iso" @
    7 expression E, F;
    8 type T;
    9 identifier V;
   10 identifier NI =~ "_NULL$";
   11 @@
   12 (
   13 
   14 (
   15   E = zalloc_flags(F, \(Z_NOFAIL\|Z_NOFAIL | ...\));
   16 |
   17   E = kalloc_type(F, \(Z_NOFAIL\|Z_NOFAIL | ...\));
   18 |
   19   E = \(kalloc_data\|kalloc_flags\)(F, \(Z_NOFAIL\|Z_NOFAIL | ...\));
   20 |
   21 - E = zalloc(F);
   22 + E = zalloc_flags(F, Z_WAITOK | Z_NOFAIL);
   23 |
   24   E = zalloc_flags(F, \(Z_WAITOK\| Z_WAITOK | ...\)
   25 + | Z_NOFAIL
   26   );
   27 |
   28   E = kalloc_type(T, \(Z_WAITOK\| Z_WAITOK | ...\)
   29 + | Z_NOFAIL
   30   );
   31 |
   32   E = \(kalloc_data\|kalloc_flags\)(sizeof(F), \(Z_WAITOK\| Z_WAITOK | ...\)
   33 + | Z_NOFAIL
   34   );
   35 |
   36 - E = kalloc(sizeof(F));
   37 + E = kalloc_flags(sizeof(F), Z_WAITOK | Z_NOFAIL);
   38 )
   39   ...
   40 (
   41 - if (\(E\|E != 0\|E != NULL\|E != NI\)) {
   42   ...
   43 - }
   44 |
   45 - if (\(!E\|E == 0\|E == NULL\|E == NI\)) {
   46 - ...
   47 - }
   48 |
   49 - assert(\(E\|E != 0\|E != NULL\|E != NI\));
   50 )
   51 
   52 |
   53 
   54 (
   55   T V = zalloc_flags(F, \(Z_NOFAIL\|Z_NOFAIL | ...\));
   56 |
   57   T V = kalloc_type(T, \(Z_NOFAIL\|Z_NOFAIL | ...\));
   58 |
   59   T V = \(kalloc_data\|kalloc_flags\)(F, \(Z_NOFAIL\|Z_NOFAIL | ...\));
   60 |
   61 - T V = kalloc(sizeof(F));
   62 + T V = kalloc_flags(sizeof(F), Z_WAITOK | Z_NOFAIL);
   63 |
   64   T V = kalloc_type(T, \(Z_WAITOK\| Z_WAITOK | ...\)
   65 + | Z_NOFAIL
   66   );
   67 |
   68   T V = \(kalloc_data\|kalloc_flags\)(sizeof(F), \(Z_WAITOK\| Z_WAITOK | ...\)
   69 + | Z_NOFAIL
   70   );
   71 )
   72   ...
   73 (
   74 - if (\(V\|V != 0\|V != NULL\|V != NI\)) {
   75   ...
   76 - }
   77 |
   78 - if (\(!V\|V == 0\|V == NULL\|V == NI\)) {
   79 - ...
   80 - }
   81 |
   82 - assert(\(V\|V != 0\|V != NULL\|V != NI\));
   83 )
   84 
   85 )
   86 
   87 // vim:ft=diff:

Cache object: b843969ac8bc6b6b3823bf4c02fdac46


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.