qr{${Ident}_handler_fn},
qr{target_(?:u)?long},
qr{hwaddr},
+ qr{xml${Ident}},
);
# This can be modified by sub possible. Since it can be empty, be careful
# check we are in a valid source file if not then ignore this hunk
next if ($realfile !~ /$SrcFile/);
-#90 column limit
+#90 column limit; exempt URLs, if no other words on line
if ($line =~ /^\+/ &&
!($line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
+ !($rawline =~ /^[^[:alnum:]]*https?:\S*$/) &&
$length > 80)
{
if ($length > 90) {
}
}
+# 'do ... while (0/false)' only makes sense in macros, without trailing ';'
+ if ($line =~ /while\s*\((0|false)\);/) {
+ ERROR("suspicious ; after while (0)\n" . $herecurr);
+ }
+
# Check relative indent for conditionals and blocks.
if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
my ($s, $c) = ($stat, $cond);
}
}
-# check for missing bracing round if etc
- if ($line =~ /(^.*)\bif\b/ && $line !~ /\#\s*if/) {
+# check for missing bracing around if etc
+ if ($line =~ /(^.*)\b(?:if|while|for)\b/ &&
+ $line !~ /\#\s*if/) {
my ($level, $endln, @chunks) =
ctx_statement_full($linenr, $realcnt, 1);
if ($dbg_adv_apw) {
# no volatiles please
my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b};
- if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) {
- ERROR("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);
+ if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/ &&
+ $line !~ /sig_atomic_t/ &&
+ !ctx_has_comment($first_line, $linenr)) {
+ my $msg = "Use of volatile is usually wrong, please add a comment\n" . $herecurr;
+ ERROR($msg);
}
# warn about #if 0
ERROR("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr);
}
+# recommend g_path_get_* over g_strdup(basename/dirname(...))
+ if ($line =~ /\bg_strdup\s*\(\s*(basename|dirname)\s*\(/) {
+ WARN("consider using g_path_get_$1() in preference to g_strdup($1())\n" . $herecurr);
+ }
+
# recommend qemu_strto* over strto* for numeric conversions
if ($line =~ /\b(strto[^kd].*?)\s*\(/) {
ERROR("consider using qemu_$1 in preference to $1\n" . $herecurr);
SCSIBusInfo|
SCSIReqOps|
Spice[A-Z][a-zA-Z0-9]*Interface|
- TPMDriverOps|
USBDesc[A-Z][a-zA-Z0-9]*|
VhostOps|
VMStateDescription|