)]}'
{
  "commit": "b88556979b65914d8b0fc85861efeaa9ad9a1d3c",
  "tree": "6cff97d21bb2d3648a3103d55cd22b6a4ce1eb6d",
  "parents": [
    "61a8bd27fb5ff27db98e96b462957994e7cca946"
  ],
  "author": {
    "name": "Carl-Daniel Hailfinger",
    "email": "c-d.hailfinger.devel.2006@gmx.net",
    "time": "Fri Mar 06 00:40:25 2009 +0000"
  },
  "committer": {
    "name": "Carl-Daniel Hailfinger",
    "email": "c-d.hailfinger.devel.2006@gmx.net",
    "time": "Fri Mar 06 00:40:25 2009 +0000"
  },
  "message": "Reduce use of volatile variables\n\nDuring the conversion of flash chip accesses to helper functions, I spotted\nassignments to volatile variables which were neither placed inside the mmapped\nROM area nor were they counters.\nDue to the use of accessor functions, volatile usage can be reduced\nsignificantly because the accessor functions take care of actually\nperforming the reads/writes correctly.\n\nThe following semantic patch spotted them (linebreak in python string\nfor readability reasons, please remove before usage):\n@r exists@\nexpression b;\ntypedef uint8_t;\nvolatile uint8_t a;\nposition p1;\n@@\n a@p1 \u003d readb(b);\n\n@script:python@\np1 \u003c\u003c r.p1;\na \u003c\u003c r.a;\nb \u003c\u003c r.b;\n@@\nprint \"* file: %s line %s has assignment to unnecessarily volatile\nvariable: %s \u003d readb(%s);\" % (p1[0].file, p1[0].line, a, b)\n\nResult was:\nHANDLING: sst28sf040.c\n* file: sst28sf040.c line 44 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 43 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 42 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 41 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 40 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 39 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 38 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 58 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 57 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 56 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 55 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 54 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 53 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n* file: sst28sf040.c line 52 has assignment to unnecessarily volatile\nvariable: tmp \u003d readb(TODO: Binary);\n\nThe following semantic patch uses the spatch builtin match printing\nfunctionality by prepending a \"*\" to the line with the pattern:\n@@\nexpression b;\ntypedef uint8_t;\nvolatile uint8_t a;\n@@\n* a \u003d readb(b);\n\nResult is:\nHANDLING: sst28sf040.c\ndiff \u003d\n-       tmp \u003d readb(bios + 0x1823);\n-       tmp \u003d readb(bios + 0x1820);\n-       tmp \u003d readb(bios + 0x1822);\n-       tmp \u003d readb(bios + 0x0418);\n-       tmp \u003d readb(bios + 0x041B);\n-       tmp \u003d readb(bios + 0x0419);\n-       tmp \u003d readb(bios + 0x040A);\n }\n \n static __inline__ void unprotect_28sf040(volatile uint8_t *bios)\n@@ -49,13 +42,6 @@ static __inline__ void unprotect_28sf040\n        /* ask compiler not to optimize this */\n        volatile uint8_t tmp;\n \n-       tmp \u003d readb(bios + 0x1823);\n-       tmp \u003d readb(bios + 0x1820);\n-       tmp \u003d readb(bios + 0x1822);\n-       tmp \u003d readb(bios + 0x0418);\n-       tmp \u003d readb(bios + 0x041B);\n-       tmp \u003d readb(bios + 0x0419);\n-       tmp \u003d readb(bios + 0x041A);\n }\n \n static __inline__ int erase_sector_28sf040(volatile uint8_t *bios,\n\nIt\u0027s arguably a bit easier to read if you get used to the leading \"-\"\nfor matching lines.\n\nThis patch was enabled by Coccinelle:\nhttp://www.emn.fr/x-info/coccinelle/\n\nCorresponding to flashrom svn r419 and coreboot v2 svn r3973.\n\nSigned-off-by: Carl-Daniel Hailfinger \u003cc-d.hailfinger.devel.2006@gmx.net\u003e\nAcked-by: Joseph Smith \u003cjoe@settoplinux.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "ee8ee809907ee10888b205deead4d0b0f778811b",
      "old_mode": 33188,
      "old_path": "sst28sf040.c",
      "new_id": "7adfcfda46d4b4818dc0e1ff7394bae7de1bf449",
      "new_mode": 33188,
      "new_path": "sst28sf040.c"
    }
  ]
}
