-#!/usr/bin/perl -w
+#!/usr/bin/env perl
# (c) 2001, Dave Jones. (the file handling bit)
# Licensed under the terms of the GNU GPL License version 2
use strict;
+use warnings;
my $P = $0;
$P =~ s@.*/@@g;
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
ERROR("DOS line endings\n" . $herevet);
+ } elsif ($realfile =~ /^docs\/.+\.txt/ ||
+ $realfile =~ /^docs\/.+\.md/) {
+ if ($rawline =~ /^\+\s+$/ && $rawline !~ /^\+ {4}$/) {
+ # TODO: properly check we're in a code block
+ # (surrounding text is 4-column aligned)
+ my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+ ERROR("code blocks in documentation should have " .
+ "empty lines with exactly 4 columns of " .
+ "whitespace\n" . $herevet);
+ }
} elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) {
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
ERROR("trailing whitespace\n" . $herevet);
# Ignore those directives where spaces _are_ permitted.
if ($name =~ /^(?:
if|for|while|switch|return|case|
- volatile|__volatile__|
+ volatile|__volatile__|coroutine_fn|
__attribute__|format|__extension__|
asm|__asm__)$/x)
{
# we have e.g. CONFIG_LINUX and CONFIG_WIN32 for common cases
# where they might be necessary.
if ($line =~ m@^.\s*\#\s*if.*\b__@) {
- ERROR("architecture specific defines should be avoided\n" . $herecurr);
+ WARN("architecture specific defines should be avoided\n" . $herecurr);
}
# Check that the storage class is at the beginning of a declaration
if ($line =~ /\b(strto[^kd].*?)\s*\(/) {
ERROR("consider using qemu_$1 in preference to $1\n" . $herecurr);
}
+# recommend sigaction over signal for portability, when establishing a handler
+ if ($line =~ /\bsignal\s*\(/ && !($line =~ /SIG_(?:IGN|DFL)/)) {
+ ERROR("use sigaction to establish signal handlers; signal is not portable\n" . $herecurr);
+ }
# check for module_init(), use category-specific init macros explicitly please
if ($line =~ /^module_init\s*\(/) {
ERROR("please use block_init(), type_init() etc. instead of module_init()\n" . $herecurr);
VMStateDescription|
VMStateInfo}x;
if ($line !~ /\bconst\b/ &&
- $line =~ /\b($struct_ops)\b/) {
- ERROR("struct $1 should normally be const\n" .
+ $line =~ /\b($struct_ops)\b.*=/) {
+ ERROR("initializer for struct $1 should normally be const\n" .
$herecurr);
}
error_setg_file_open|
error_set|
error_prepend|
+ warn_reportf_err|
error_reportf_err|
error_vreport|
- error_report}x;
+ warn_vreport|
+ info_vreport|
+ error_report|
+ warn_report|
+ info_report}x;
if ($rawline =~ /\b(?:$qemu_error_funcs)\s*\(.*\".*\\n/) {
ERROR("Error messages should not contain newlines\n" . $herecurr);
if ($line =~ /\bbzero\(/) {
ERROR("use memset() instead of bzero()\n" . $herecurr);
}
+ my $non_exit_glib_asserts = qr{g_assert_cmpstr|
+ g_assert_cmpint|
+ g_assert_cmpuint|
+ g_assert_cmphex|
+ g_assert_cmpfloat|
+ g_assert_true|
+ g_assert_false|
+ g_assert_nonnull|
+ g_assert_null|
+ g_assert_no_error|
+ g_assert_error|
+ g_test_assert_expected_messages|
+ g_test_trap_assert_passed|
+ g_test_trap_assert_stdout|
+ g_test_trap_assert_stdout_unmatched|
+ g_test_trap_assert_stderr|
+ g_test_trap_assert_stderr_unmatched}x;
+ if ($realfile !~ /^tests\// &&
+ $line =~ /\b(?:$non_exit_glib_asserts)\(/) {
+ ERROR("Use g_assert or g_assert_not_reached\n". $herecurr);
+ }
}
# If we have no input at all, then there is nothing to report on