err-bad-newline.cocci (925B)
1// Error messages should not contain newlines. This script finds 2// messages that do. Fixing them is manual. 3@r@ 4expression errp, err, eno, cls, fmt, ap; 5position p; 6@@ 7( 8error_vreport(fmt, ap)@p 9| 10warn_vreport(fmt, ap)@p 11| 12info_vreport(fmt, ap)@p 13| 14error_report(fmt, ...)@p 15| 16warn_report(fmt, ...)@p 17| 18info_report(fmt, ...)@p 19| 20error_report_once(fmt, ...)@p 21| 22warn_report_once(fmt, ...)@p 23| 24error_setg(errp, fmt, ...)@p 25| 26error_setg_errno(errp, eno, fmt, ...)@p 27| 28error_setg_win32(errp, eno, cls, fmt, ...)@p 29| 30error_propagate_prepend(errp, err, fmt, ...)@p 31| 32error_vprepend(errp, fmt, ap)@p 33| 34error_prepend(errp, fmt, ...)@p 35| 36error_setg_file_open(errp, eno, cls, fmt, ...)@p 37| 38warn_reportf_err(errp, fmt, ...)@p 39| 40error_reportf_err(errp, fmt, ...)@p 41| 42error_set(errp, cls, fmt, ...)@p 43) 44@script:python@ 45fmt << r.fmt; 46p << r.p; 47@@ 48if "\\n" in str(fmt): 49 print("%s:%s:%s:%s" % (p[0].file, p[0].line, p[0].column, fmt))