mirror of https://gitee.com/openkylin/qemu.git
* pc-bios/optionrom/Makefile fixes
* warning fixes for __atomic_load and -1 << x in clang * missed interrupt fix from Gonglei * checkpatch fix from Radim and myself -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQEcBAABAgAGBQJXqzIXAAoJEL/70l94x66DKjUH/jLaufcZE3jLekhChGilN5Mp TVNZtsBnpYup+sgDa9u95gU6xylk9DOtledzPUnNdKZlnwamc3GluIklChpqItz0 kMkk8YO9Fe5oIrL0llcoWuSyStZ8mU6icwrROXwfYHJMsK4D/5ZvrfJcUmMU6bxO iymBCoL4T6MnOwMiztWL/swCnZtnilwDbo00z1PCycGA2UE0wSLryPkgFgNrUQk6 DiLrcPsrWxHgDHrknv5jaGKmjsN5fOaMAPJbXTXFh/QU6agUI/nqGTp54T6TuZ09 sWijYPcpsj+6g4tqAEyM8CkIlOYywmsT7eIER3Yg6Byhu8Ce0oRzEB0sNLiUiao= =Z6ET -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging * pc-bios/optionrom/Makefile fixes * warning fixes for __atomic_load and -1 << x in clang * missed interrupt fix from Gonglei * checkpatch fix from Radim and myself # gpg: Signature made Wed 10 Aug 2016 14:54:31 BST # gpg: using RSA key 0xBFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: checkpatch: default to success if only warnings checkpatch: bump most warnings to errors CODING_STYLE, checkpatch: update line length rules checkpatch: check for CVS keywords on all sources checkpatch: tweak the files in which TABs are checked timer: set vm_clock disabled default checkpatch: ignore automatically imported Linux headers clang: Fix warning reg. expansion to 'defined' Disable warn about left shifts of negative values atomic: strip "const" from variables declared with typeof optionrom: fix compilation with mingw docker target optionrom: add -fno-stack-protector build-sys: fix building with make CFLAGS=.. argument linuxboot_dma: avoid guest ABI breakage on gcc vs. clang compilation Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
4b3e5c06a1
|
@ -31,7 +31,11 @@ Do not leave whitespace dangling off the ends of lines.
|
|||
|
||||
2. Line width
|
||||
|
||||
Lines are 80 characters; not longer.
|
||||
Lines should be 80 characters; try not to make them longer.
|
||||
|
||||
Sometimes it is hard to do, especially when dealing with QEMU subsystems
|
||||
that use long function or symbol names. Even in that case, do not make
|
||||
lines much longer than 80 characters.
|
||||
|
||||
Rationale:
|
||||
- Some people like to tile their 24" screens with a 6x4 matrix of 80x24
|
||||
|
@ -39,6 +43,8 @@ Rationale:
|
|||
let them keep doing it.
|
||||
- Code and especially patches is much more readable if limited to a sane
|
||||
line length. Eighty is traditional.
|
||||
- The four-space indentation makes the most common excuse ("But look
|
||||
at all that white space on the left!") moot.
|
||||
- It is the QEMU coding style.
|
||||
|
||||
3. Naming
|
||||
|
|
4
HACKING
4
HACKING
|
@ -158,6 +158,10 @@ painful. These are:
|
|||
* you may assume that right shift of a signed integer duplicates
|
||||
the sign bit (ie it is an arithmetic shift, not a logical shift)
|
||||
|
||||
In addition, QEMU assumes that the compiler does not use the latitude
|
||||
given in C99 and C11 to treat aspects of signed '<<' as undefined, as
|
||||
documented in the GNU Compiler Collection manual starting at version 4.0.
|
||||
|
||||
7. Error handling and reporting
|
||||
|
||||
7.1 Reporting errors to the human user
|
||||
|
|
3
Makefile
3
Makefile
|
@ -225,8 +225,9 @@ dtc/%:
|
|||
$(SUBDIR_RULES): libqemuutil.a libqemustub.a $(common-obj-y) $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY))
|
||||
|
||||
ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
|
||||
# Only keep -O and -g cflags
|
||||
romsubdir-%:
|
||||
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pc-bios/$* V="$(V)" TARGET_DIR="$*/",)
|
||||
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pc-bios/$* V="$(V)" TARGET_DIR="$*/" CFLAGS="$(filter -O% -g%,$(CFLAGS))",)
|
||||
|
||||
ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
|
||||
|
||||
|
|
|
@ -1452,7 +1452,7 @@ fi
|
|||
gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
|
||||
gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
|
||||
gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
|
||||
gcc_flags="-Wendif-labels $gcc_flags"
|
||||
gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
|
||||
gcc_flags="-Wno-initializer-overrides $gcc_flags"
|
||||
gcc_flags="-Wno-string-plus-int $gcc_flags"
|
||||
# Note that we do not add -Werror to gcc_flags here, because that would
|
||||
|
|
|
@ -18,6 +18,48 @@
|
|||
/* Compiler barrier */
|
||||
#define barrier() ({ asm volatile("" ::: "memory"); (void)0; })
|
||||
|
||||
/* The variable that receives the old value of an atomically-accessed
|
||||
* variable must be non-qualified, because atomic builtins return values
|
||||
* through a pointer-type argument as in __atomic_load(&var, &old, MODEL).
|
||||
*
|
||||
* This macro has to handle types smaller than int manually, because of
|
||||
* implicit promotion. int and larger types, as well as pointers, can be
|
||||
* converted to a non-qualified type just by applying a binary operator.
|
||||
*/
|
||||
#define typeof_strip_qual(expr) \
|
||||
typeof( \
|
||||
__builtin_choose_expr( \
|
||||
__builtin_types_compatible_p(typeof(expr), bool) || \
|
||||
__builtin_types_compatible_p(typeof(expr), const bool) || \
|
||||
__builtin_types_compatible_p(typeof(expr), volatile bool) || \
|
||||
__builtin_types_compatible_p(typeof(expr), const volatile bool), \
|
||||
(bool)1, \
|
||||
__builtin_choose_expr( \
|
||||
__builtin_types_compatible_p(typeof(expr), signed char) || \
|
||||
__builtin_types_compatible_p(typeof(expr), const signed char) || \
|
||||
__builtin_types_compatible_p(typeof(expr), volatile signed char) || \
|
||||
__builtin_types_compatible_p(typeof(expr), const volatile signed char), \
|
||||
(signed char)1, \
|
||||
__builtin_choose_expr( \
|
||||
__builtin_types_compatible_p(typeof(expr), unsigned char) || \
|
||||
__builtin_types_compatible_p(typeof(expr), const unsigned char) || \
|
||||
__builtin_types_compatible_p(typeof(expr), volatile unsigned char) || \
|
||||
__builtin_types_compatible_p(typeof(expr), const volatile unsigned char), \
|
||||
(unsigned char)1, \
|
||||
__builtin_choose_expr( \
|
||||
__builtin_types_compatible_p(typeof(expr), signed short) || \
|
||||
__builtin_types_compatible_p(typeof(expr), const signed short) || \
|
||||
__builtin_types_compatible_p(typeof(expr), volatile signed short) || \
|
||||
__builtin_types_compatible_p(typeof(expr), const volatile signed short), \
|
||||
(signed short)1, \
|
||||
__builtin_choose_expr( \
|
||||
__builtin_types_compatible_p(typeof(expr), unsigned short) || \
|
||||
__builtin_types_compatible_p(typeof(expr), const unsigned short) || \
|
||||
__builtin_types_compatible_p(typeof(expr), volatile unsigned short) || \
|
||||
__builtin_types_compatible_p(typeof(expr), const volatile unsigned short), \
|
||||
(unsigned short)1, \
|
||||
(expr)+0))))))
|
||||
|
||||
#ifdef __ATOMIC_RELAXED
|
||||
/* For C11 atomic ops */
|
||||
|
||||
|
@ -54,7 +96,7 @@
|
|||
#define atomic_read(ptr) \
|
||||
({ \
|
||||
QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \
|
||||
typeof(*ptr) _val; \
|
||||
typeof_strip_qual(*ptr) _val; \
|
||||
__atomic_load(ptr, &_val, __ATOMIC_RELAXED); \
|
||||
_val; \
|
||||
})
|
||||
|
@ -80,7 +122,7 @@
|
|||
#define atomic_rcu_read(ptr) \
|
||||
({ \
|
||||
QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \
|
||||
typeof(*ptr) _val; \
|
||||
typeof_strip_qual(*ptr) _val; \
|
||||
atomic_rcu_read__nocheck(ptr, &_val); \
|
||||
_val; \
|
||||
})
|
||||
|
@ -103,7 +145,7 @@
|
|||
#define atomic_mb_read(ptr) \
|
||||
({ \
|
||||
QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \
|
||||
typeof(*ptr) _val; \
|
||||
typeof_strip_qual(*ptr) _val; \
|
||||
__atomic_load(ptr, &_val, __ATOMIC_RELAXED); \
|
||||
smp_rmb(); \
|
||||
_val; \
|
||||
|
@ -120,7 +162,7 @@
|
|||
#define atomic_mb_read(ptr) \
|
||||
({ \
|
||||
QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \
|
||||
typeof(*ptr) _val; \
|
||||
typeof_strip_qual(*ptr) _val; \
|
||||
__atomic_load(ptr, &_val, __ATOMIC_SEQ_CST); \
|
||||
_val; \
|
||||
})
|
||||
|
@ -137,7 +179,7 @@
|
|||
|
||||
#define atomic_xchg(ptr, i) ({ \
|
||||
QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \
|
||||
typeof(*ptr) _new = (i), _old; \
|
||||
typeof_strip_qual(*ptr) _new = (i), _old; \
|
||||
__atomic_exchange(ptr, &_new, &_old, __ATOMIC_SEQ_CST); \
|
||||
_old; \
|
||||
})
|
||||
|
@ -146,7 +188,7 @@
|
|||
#define atomic_cmpxchg(ptr, old, new) \
|
||||
({ \
|
||||
QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \
|
||||
typeof(*ptr) _old = (old), _new = (new); \
|
||||
typeof_strip_qual(*ptr) _old = (old), _new = (new); \
|
||||
__atomic_compare_exchange(ptr, &_old, &_new, false, \
|
||||
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \
|
||||
_old; \
|
||||
|
|
|
@ -42,8 +42,11 @@ int qemu_spice_set_pw_expire(time_t expires);
|
|||
int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,
|
||||
const char *subject);
|
||||
|
||||
#define SPICE_NEEDS_SET_MM_TIME \
|
||||
(!defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06))
|
||||
#if !defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06)
|
||||
#define SPICE_NEEDS_SET_MM_TIME 1
|
||||
#else
|
||||
#define SPICE_NEEDS_SET_MM_TIME 0
|
||||
#endif
|
||||
|
||||
#if SPICE_SERVER_VERSION >= 0x000c02
|
||||
void qemu_spice_register_ports(void);
|
||||
|
|
Binary file not shown.
|
@ -9,8 +9,17 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
|
|||
|
||||
.PHONY : all clean build-all
|
||||
|
||||
# Compiling with no optimization creates ROMs that are too large
|
||||
ifeq ($(filter -O%, $(CFLAGS)),)
|
||||
override CFLAGS += -O2
|
||||
endif
|
||||
ifeq ($(filter -O%, $(CFLAGS)),-O0)
|
||||
override CFLAGS += -O2
|
||||
endif
|
||||
|
||||
# Drop -fstack-protector and the like
|
||||
QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) $(CFLAGS_NOPIE) -ffreestanding
|
||||
QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
|
||||
QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -m16)
|
||||
ifeq ($(filter -m16, $(QEMU_CFLAGS)),)
|
||||
# Attempt to work around compilers that lack -m16 (GCC <= 4.8, clang <= ??)
|
||||
|
@ -24,8 +33,6 @@ QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -no-integrated-as)
|
|||
QEMU_CFLAGS += -m32 -include $(SRC_PATH)/pc-bios/optionrom/code16gcc.h
|
||||
endif
|
||||
|
||||
# Drop gcov and glib flags
|
||||
CFLAGS := $(filter -O% -g%, $(CFLAGS))
|
||||
QEMU_INCLUDES += -I$(SRC_PATH)
|
||||
|
||||
Wa = -Wa,
|
||||
|
@ -52,7 +59,7 @@ endif
|
|||
endif
|
||||
|
||||
%.img: %.o
|
||||
$(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_EMULATION) -Ttext 0 -e _start -s -o $@ $<," Building $(TARGET_DIR)$@")
|
||||
$(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_EMULATION) -T $(SRC_PATH)/pc-bios/optionrom/flat.lds -s -o $@ $<," Building $(TARGET_DIR)$@")
|
||||
|
||||
%.raw: %.img
|
||||
$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@," Building $(TARGET_DIR)$@")
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
SECTIONS
|
||||
{
|
||||
. = 0;
|
||||
.text : { *(.text) *(.text.$) }
|
||||
}
|
||||
ENTRY(_start)
|
|
@ -25,7 +25,7 @@ asm(
|
|||
".global _start\n"
|
||||
"_start:\n"
|
||||
" .short 0xaa55\n"
|
||||
" .byte 0\n" /* size in 512 units, filled in by signrom.py */
|
||||
" .byte 3\n" /* desired size in 512 units; signrom.py adds padding */
|
||||
" .byte 0xcb\n" /* far return without prefix */
|
||||
" .org 0x18\n"
|
||||
" .short 0\n"
|
||||
|
@ -157,7 +157,11 @@ static inline uint32_t be32_to_cpu(uint32_t x)
|
|||
return bswap32(x);
|
||||
}
|
||||
|
||||
static void bios_cfg_read_entry(void *buf, uint16_t entry, uint32_t len)
|
||||
/* clang is happy to inline this function, and bloats the
|
||||
* ROM.
|
||||
*/
|
||||
static __attribute__((__noinline__))
|
||||
void bios_cfg_read_entry(void *buf, uint16_t entry, uint32_t len)
|
||||
{
|
||||
FWCfgDmaAccess access;
|
||||
uint32_t control = (entry << 16) | BIOS_CFG_DMA_CTL_SELECT
|
||||
|
|
|
@ -129,7 +129,7 @@ static void qemu_clock_init(QEMUClockType type)
|
|||
assert(main_loop_tlg.tl[type] == NULL);
|
||||
|
||||
clock->type = type;
|
||||
clock->enabled = true;
|
||||
clock->enabled = (type == QEMU_CLOCK_VIRTUAL ? false : true);
|
||||
clock->last = INT64_MIN;
|
||||
QLIST_INIT(&clock->timerlists);
|
||||
notifier_list_init(&clock->reset_notifiers);
|
||||
|
|
|
@ -22,7 +22,7 @@ my $tst_only;
|
|||
my $emacs = 0;
|
||||
my $terse = 0;
|
||||
my $file = 0;
|
||||
my $check = 0;
|
||||
my $no_warnings = 0;
|
||||
my $summary = 1;
|
||||
my $mailback = 0;
|
||||
my $summary_file = 0;
|
||||
|
@ -45,7 +45,7 @@ Options:
|
|||
--emacs emacs compile window format
|
||||
--terse one line per report
|
||||
-f, --file treat FILE as regular source file
|
||||
--subjective, --strict enable more subjective tests
|
||||
--strict fail if only warnings are found
|
||||
--root=PATH PATH to the kernel tree root
|
||||
--no-summary suppress the per-file summary
|
||||
--mailback only produce a report in case of warnings/errors
|
||||
|
@ -71,8 +71,7 @@ GetOptions(
|
|||
'emacs!' => \$emacs,
|
||||
'terse!' => \$terse,
|
||||
'f|file!' => \$file,
|
||||
'subjective!' => \$check,
|
||||
'strict!' => \$check,
|
||||
'strict!' => \$no_warnings,
|
||||
'root=s' => \$root,
|
||||
'summary!' => \$summary,
|
||||
'mailback!' => \$mailback,
|
||||
|
@ -1072,12 +1071,6 @@ sub WARN {
|
|||
our $cnt_warn++;
|
||||
}
|
||||
}
|
||||
sub CHK {
|
||||
if ($check && report("CHECK: $_[0]\n")) {
|
||||
our $clean = 0;
|
||||
our $cnt_chk++;
|
||||
}
|
||||
}
|
||||
|
||||
sub process {
|
||||
my $filename = shift;
|
||||
|
@ -1289,11 +1282,11 @@ sub process {
|
|||
# This is a signoff, if ugly, so do not double report.
|
||||
$signoff++;
|
||||
if (!($line =~ /^\s*Signed-off-by:/)) {
|
||||
WARN("Signed-off-by: is the preferred form\n" .
|
||||
ERROR("The correct form is \"Signed-off-by\"\n" .
|
||||
$herecurr);
|
||||
}
|
||||
if ($line =~ /^\s*signed-off-by:\S/i) {
|
||||
WARN("space required after Signed-off-by:\n" .
|
||||
ERROR("space required after Signed-off-by:\n" .
|
||||
$herecurr);
|
||||
}
|
||||
}
|
||||
|
@ -1319,6 +1312,9 @@ sub process {
|
|||
# ignore non-hunk lines and lines being removed
|
||||
next if (!$hunk_line || $line =~ /^-/);
|
||||
|
||||
# ignore files that are being periodically imported from Linux
|
||||
next if ($realfile =~ /^(linux-headers|include\/standard-headers)\//);
|
||||
|
||||
#trailing whitespace
|
||||
if ($line =~ /^\+.*\015/) {
|
||||
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
|
||||
|
@ -1331,30 +1327,40 @@ sub process {
|
|||
}
|
||||
|
||||
# check we are in a valid source file if not then ignore this hunk
|
||||
next if ($realfile !~ /\.(h|c|cpp|s|S|pl|sh)$/);
|
||||
next if ($realfile !~ /\.(h|c|cpp|s|S|pl|py|sh)$/);
|
||||
|
||||
#80 column limit
|
||||
#90 column limit
|
||||
if ($line =~ /^\+/ &&
|
||||
!($line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
|
||||
$length > 80)
|
||||
{
|
||||
WARN("line over 80 characters\n" . $herecurr);
|
||||
if ($length > 90) {
|
||||
ERROR("line over 90 characters\n" . $herecurr);
|
||||
} else {
|
||||
WARN("line over 80 characters\n" . $herecurr);
|
||||
}
|
||||
}
|
||||
|
||||
# check for spaces before a quoted newline
|
||||
if ($rawline =~ /^.*\".*\s\\n/) {
|
||||
WARN("unnecessary whitespace before a quoted newline\n" . $herecurr);
|
||||
ERROR("unnecessary whitespace before a quoted newline\n" . $herecurr);
|
||||
}
|
||||
|
||||
# check for adding lines without a newline.
|
||||
if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) {
|
||||
WARN("adding a line without newline at end of file\n" . $herecurr);
|
||||
ERROR("adding a line without newline at end of file\n" . $herecurr);
|
||||
}
|
||||
|
||||
# check we are in a valid source file C or perl if not then ignore this hunk
|
||||
next if ($realfile !~ /\.(h|c|cpp|pl)$/);
|
||||
# check for RCS/CVS revision markers
|
||||
if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|\b)/) {
|
||||
ERROR("CVS style keyword markers, these will _not_ be updated\n". $herecurr);
|
||||
}
|
||||
|
||||
# tabs are only allowed in assembly source code, and in
|
||||
# some scripts we imported from other projects.
|
||||
next if ($realfile =~ /\.(s|S)$/);
|
||||
next if ($realfile =~ /(checkpatch|get_maintainer|texi2pod)\.pl$/);
|
||||
|
||||
# in QEMU, no tabs are allowed
|
||||
if ($rawline =~ /^\+.*\t/) {
|
||||
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
|
||||
ERROR("code indent should never use tabs\n" . $herevet);
|
||||
|
@ -1364,11 +1370,6 @@ sub process {
|
|||
# check we are in a valid C source file if not then ignore this hunk
|
||||
next if ($realfile !~ /\.(h|c|cpp)$/);
|
||||
|
||||
# check for RCS/CVS revision markers
|
||||
if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) {
|
||||
WARN("CVS style keyword markers, these will _not_ be updated\n". $herecurr);
|
||||
}
|
||||
|
||||
# Check for potential 'bare' types
|
||||
my ($stat, $cond, $line_nr_next, $remain_next, $off_next,
|
||||
$realline_next);
|
||||
|
@ -1498,7 +1499,7 @@ sub process {
|
|||
{
|
||||
my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]);
|
||||
if ($nindent > $indent) {
|
||||
WARN("trailing semicolon indicates no statements, indent implies otherwise\n" .
|
||||
ERROR("trailing semicolon indicates no statements, indent implies otherwise\n" .
|
||||
"$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
|
||||
}
|
||||
}
|
||||
|
@ -1586,7 +1587,7 @@ sub process {
|
|||
|
||||
if ($check && (($sindent % 4) != 0 ||
|
||||
($sindent <= $indent && $s ne ''))) {
|
||||
WARN("suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");
|
||||
ERROR("suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1764,7 +1765,7 @@ sub process {
|
|||
} elsif ($ctx =~ /$Type$/) {
|
||||
|
||||
} else {
|
||||
WARN("space prohibited between function name and open parenthesis '('\n" . $herecurr);
|
||||
ERROR("space prohibited between function name and open parenthesis '('\n" . $herecurr);
|
||||
}
|
||||
}
|
||||
# Check operator spacing.
|
||||
|
@ -2003,7 +2004,7 @@ sub process {
|
|||
if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) {
|
||||
my $name = $1;
|
||||
if ($name ne 'EOF' && $name ne 'ERROR') {
|
||||
WARN("return of an errno should typically be -ve (return -$1)\n" . $herecurr);
|
||||
ERROR("return of an errno should typically be -ve (return -$1)\n" . $herecurr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2075,7 +2076,7 @@ sub process {
|
|||
(?:\&\&|\|\||\)|\])
|
||||
)/x)
|
||||
{
|
||||
WARN("boolean test with hexadecimal, perhaps just 1 \& or \|?\n" . $herecurr);
|
||||
ERROR("boolean test with hexadecimal, perhaps just 1 \& or \|?\n" . $herecurr);
|
||||
}
|
||||
|
||||
# if and else should not have general statements after it
|
||||
|
@ -2131,7 +2132,7 @@ sub process {
|
|||
|
||||
#no spaces allowed after \ in define
|
||||
if ($line=~/\#\s*define.*\\\s$/) {
|
||||
WARN("Whitepspace after \\ makes next lines useless\n" . $herecurr);
|
||||
ERROR("Whitespace after \\ makes next lines useless\n" . $herecurr);
|
||||
}
|
||||
|
||||
# multi-statement macros should be enclosed in a do while loop, grab the
|
||||
|
@ -2283,7 +2284,7 @@ sub process {
|
|||
}
|
||||
}
|
||||
if ($seen != ($#chunks + 1)) {
|
||||
WARN("braces {} are necessary for all arms of this statement\n" . $herectx);
|
||||
ERROR("braces {} are necessary for all arms of this statement\n" . $herectx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2351,19 +2352,19 @@ sub process {
|
|||
$herectx .= raw_line($linenr, $n) . "\n";;
|
||||
}
|
||||
|
||||
WARN("braces {} are necessary even for single statement blocks\n" . $herectx);
|
||||
ERROR("braces {} are necessary even for single statement blocks\n" . $herectx);
|
||||
}
|
||||
}
|
||||
|
||||
# no volatiles please
|
||||
my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b};
|
||||
if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) {
|
||||
WARN("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);
|
||||
ERROR("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);
|
||||
}
|
||||
|
||||
# warn about #if 0
|
||||
if ($line =~ /^.\s*\#\s*if\s+0\b/) {
|
||||
WARN("if this code is redundant consider removing it\n" .
|
||||
ERROR("if this code is redundant consider removing it\n" .
|
||||
$herecurr);
|
||||
}
|
||||
|
||||
|
@ -2371,7 +2372,7 @@ sub process {
|
|||
if ($prevline =~ /\bif\s*\(([^\)]*)\)/) {
|
||||
my $expr = $1;
|
||||
if ($line =~ /\bg_free\(\Q$expr\E\);/) {
|
||||
WARN("g_free(NULL) is safe this check is probably not required\n" . $hereprev);
|
||||
ERROR("g_free(NULL) is safe this check is probably not required\n" . $hereprev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2389,19 +2390,19 @@ sub process {
|
|||
# check for memory barriers without a comment.
|
||||
if ($line =~ /\b(smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) {
|
||||
if (!ctx_has_comment($first_line, $linenr)) {
|
||||
WARN("memory barrier without comment\n" . $herecurr);
|
||||
ERROR("memory barrier without comment\n" . $herecurr);
|
||||
}
|
||||
}
|
||||
# check of hardware specific defines
|
||||
# we have e.g. CONFIG_LINUX and CONFIG_WIN32 for common cases
|
||||
# where they might be necessary.
|
||||
if ($line =~ m@^.\s*\#\s*if.*\b__@) {
|
||||
WARN("architecture specific defines should be avoided\n" . $herecurr);
|
||||
ERROR("architecture specific defines should be avoided\n" . $herecurr);
|
||||
}
|
||||
|
||||
# Check that the storage class is at the beginning of a declaration
|
||||
if ($line =~ /\b$Storage\b/ && $line !~ /^.\s*$Storage\b/) {
|
||||
WARN("storage class should be at the beginning of the declaration\n" . $herecurr)
|
||||
ERROR("storage class should be at the beginning of the declaration\n" . $herecurr)
|
||||
}
|
||||
|
||||
# check the location of the inline attribute, that it is between
|
||||
|
@ -2413,7 +2414,7 @@ sub process {
|
|||
|
||||
# check for sizeof(&)
|
||||
if ($line =~ /\bsizeof\s*\(\s*\&/) {
|
||||
WARN("sizeof(& should be avoided\n" . $herecurr);
|
||||
ERROR("sizeof(& should be avoided\n" . $herecurr);
|
||||
}
|
||||
|
||||
# check for new externs in .c files.
|
||||
|
@ -2430,40 +2431,40 @@ sub process {
|
|||
if ($s =~ /^\s*;/ &&
|
||||
$function_name ne 'uninitialized_var')
|
||||
{
|
||||
WARN("externs should be avoided in .c files\n" . $herecurr);
|
||||
ERROR("externs should be avoided in .c files\n" . $herecurr);
|
||||
}
|
||||
|
||||
if ($paren_space =~ /\n/) {
|
||||
WARN("arguments for function declarations should follow identifier\n" . $herecurr);
|
||||
ERROR("arguments for function declarations should follow identifier\n" . $herecurr);
|
||||
}
|
||||
|
||||
} elsif ($realfile =~ /\.c$/ && defined $stat &&
|
||||
$stat =~ /^.\s*extern\s+/)
|
||||
{
|
||||
WARN("externs should be avoided in .c files\n" . $herecurr);
|
||||
ERROR("externs should be avoided in .c files\n" . $herecurr);
|
||||
}
|
||||
|
||||
# check for pointless casting of g_malloc return
|
||||
if ($line =~ /\*\s*\)\s*g_(try)?(m|re)alloc(0?)(_n)?\b/) {
|
||||
if ($2 == 'm') {
|
||||
WARN("unnecessary cast may hide bugs, use g_$1new$3 instead\n" . $herecurr);
|
||||
ERROR("unnecessary cast may hide bugs, use g_$1new$3 instead\n" . $herecurr);
|
||||
} else {
|
||||
WARN("unnecessary cast may hide bugs, use g_$1renew$3 instead\n" . $herecurr);
|
||||
ERROR("unnecessary cast may hide bugs, use g_$1renew$3 instead\n" . $herecurr);
|
||||
}
|
||||
}
|
||||
|
||||
# check for gcc specific __FUNCTION__
|
||||
if ($line =~ /__FUNCTION__/) {
|
||||
WARN("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr);
|
||||
ERROR("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr);
|
||||
}
|
||||
|
||||
# recommend qemu_strto* over strto* for numeric conversions
|
||||
if ($line =~ /\b(strto[^kd].*?)\s*\(/) {
|
||||
WARN("consider using qemu_$1 in preference to $1\n" . $herecurr);
|
||||
ERROR("consider using qemu_$1 in preference to $1\n" . $herecurr);
|
||||
}
|
||||
# check for module_init(), use category-specific init macros explicitly please
|
||||
if ($line =~ /^module_init\s*\(/) {
|
||||
WARN("please use block_init(), type_init() etc. instead of module_init()\n" . $herecurr);
|
||||
ERROR("please use block_init(), type_init() etc. instead of module_init()\n" . $herecurr);
|
||||
}
|
||||
# check for various ops structs, ensure they are const.
|
||||
my $struct_ops = qr{AIOCBInfo|
|
||||
|
@ -2488,7 +2489,7 @@ sub process {
|
|||
VMStateInfo}x;
|
||||
if ($line !~ /\bconst\b/ &&
|
||||
$line =~ /\b($struct_ops)\b/) {
|
||||
WARN("struct $1 should normally be const\n" .
|
||||
ERROR("struct $1 should normally be const\n" .
|
||||
$herecurr);
|
||||
}
|
||||
|
||||
|
@ -2498,14 +2499,14 @@ sub process {
|
|||
$string = substr($rawline, $-[1], $+[1] - $-[1]);
|
||||
$string =~ s/%%/__/g;
|
||||
if ($string =~ /(?<!%)%L[udi]/) {
|
||||
WARN("\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
|
||||
ERROR("\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
# QEMU specific tests
|
||||
if ($rawline =~ /\b(?:Qemu|QEmu)\b/) {
|
||||
WARN("use QEMU instead of Qemu or QEmu\n" . $herecurr);
|
||||
ERROR("use QEMU instead of Qemu or QEmu\n" . $herecurr);
|
||||
}
|
||||
|
||||
# Qemu error function tests
|
||||
|
@ -2522,7 +2523,7 @@ sub process {
|
|||
error_report}x;
|
||||
|
||||
if ($rawline =~ /\b(?:$qemu_error_funcs)\s*\(.*\".*\\n/) {
|
||||
WARN("Error messages should not contain newlines\n" . $herecurr);
|
||||
ERROR("Error messages should not contain newlines\n" . $herecurr);
|
||||
}
|
||||
|
||||
# Continue checking for error messages that contains newlines. This
|
||||
|
@ -2543,7 +2544,7 @@ sub process {
|
|||
}
|
||||
|
||||
if ($rawlines[$i] =~ /\b(?:$qemu_error_funcs)\s*\(/) {
|
||||
WARN("Error messages should not contain newlines\n" . $herecurr);
|
||||
ERROR("Error messages should not contain newlines\n" . $herecurr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2591,7 +2592,6 @@ sub process {
|
|||
if ($summary && !($clean == 1 && $quiet == 1)) {
|
||||
print "$filename " if ($summary_file);
|
||||
print "total: $cnt_error errors, $cnt_warn warnings, " .
|
||||
(($check)? "$cnt_chk checks, " : "") .
|
||||
"$cnt_lines lines checked\n";
|
||||
print "\n" if ($quiet == 0);
|
||||
}
|
||||
|
@ -2614,5 +2614,5 @@ sub process {
|
|||
print "CHECKPATCH in MAINTAINERS.\n";
|
||||
}
|
||||
|
||||
return $clean;
|
||||
return ($no_warnings ? $clean : $cnt_error == 0);
|
||||
}
|
||||
|
|
|
@ -23,26 +23,21 @@
|
|||
|
||||
size_byte = ord(fin.read(1))
|
||||
fin.seek(0)
|
||||
data = fin.read()
|
||||
|
||||
if size_byte == 0:
|
||||
# If the caller left the size field blank then we will fill it in,
|
||||
# also rounding the whole input to a multiple of 512 bytes.
|
||||
data = fin.read()
|
||||
# +1 because we need a byte to store the checksum.
|
||||
size = len(data) + 1
|
||||
# Round up to next multiple of 512.
|
||||
size += 511
|
||||
size -= size % 512
|
||||
if size >= 65536:
|
||||
sys.exit("%s: option ROM size too large" % sys.argv[1])
|
||||
size = size_byte * 512
|
||||
if len(data) > size:
|
||||
sys.stderr.write('error: ROM is too large (%d > %d)\n' % (len(data), size))
|
||||
sys.exit(1)
|
||||
elif len(data) < size:
|
||||
# Add padding if necessary, rounding the whole input to a multiple of
|
||||
# 512 bytes according to the third byte of the input.
|
||||
# size-1 because a final byte is added below to store the checksum.
|
||||
data = data.ljust(size-1, '\0')
|
||||
data = data[:2] + chr(size/512) + data[3:]
|
||||
else:
|
||||
# Otherwise the input file specifies the size so use it.
|
||||
# -1 because we overwrite the last byte of the file with the checksum.
|
||||
size = size_byte * 512 - 1
|
||||
data = fin.read(size)
|
||||
if ord(data[-1:]) != 0:
|
||||
sys.stderr.write('WARNING: ROM includes nonzero checksum\n')
|
||||
data = data[:size-1]
|
||||
|
||||
fout.write(data)
|
||||
|
||||
|
|
|
@ -452,7 +452,7 @@ static void test_timer_schedule(void)
|
|||
{
|
||||
TimerTestData data = { .n = 0, .ctx = ctx, .ns = SCALE_MS * 750LL,
|
||||
.max = 2,
|
||||
.clock_type = QEMU_CLOCK_VIRTUAL };
|
||||
.clock_type = QEMU_CLOCK_REALTIME };
|
||||
EventNotifier e;
|
||||
|
||||
/* aio_poll will not block to wait for timers to complete unless it has
|
||||
|
@ -782,7 +782,7 @@ static void test_source_timer_schedule(void)
|
|||
{
|
||||
TimerTestData data = { .n = 0, .ctx = ctx, .ns = SCALE_MS * 750LL,
|
||||
.max = 2,
|
||||
.clock_type = QEMU_CLOCK_VIRTUAL };
|
||||
.clock_type = QEMU_CLOCK_REALTIME };
|
||||
EventNotifier e;
|
||||
int64_t expiry;
|
||||
|
||||
|
|
Loading…
Reference in New Issue