]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Add BUG_ON() helper to make a run-time critical tests
authorCyrill Gorcunov <gorcunov@gmail.com>
Mon, 19 Dec 2011 08:25:45 +0000 (12:25 +0400)
committerPekka Enberg <penberg@kernel.org>
Mon, 19 Dec 2011 17:39:04 +0000 (19:39 +0200)
Also drop useless assert.h inclusions.

Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/include/kvm/util.h
tools/kvm/ioport.c
tools/kvm/kvm-cmd.c
tools/kvm/kvm.c
tools/kvm/pci.c
tools/kvm/powerpc/kvm.c
tools/kvm/virtio/console.c
tools/kvm/virtio/net.c
tools/kvm/x86/bios.c
tools/kvm/x86/cpuid.c
tools/kvm/x86/kvm.c

index 83088afe89a2a45059aaf9468a185e70fc8311e7..2792c88d6fd3042dce6aab41ebd38cee0b7a66ee 100644 (file)
@@ -9,6 +9,7 @@
  * Some bits are stolen from perf tool :)
  */
 
+#include <assert.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stddef.h>
@@ -50,7 +51,9 @@ extern void set_die_routine(void (*routine)(const char *err, va_list params) NOR
                                __func__, __LINE__, ##__VA_ARGS__);     \
        } while (0)
 
-#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
+#
+#define BUILD_BUG_ON(condition)        ((void)sizeof(char[1 - 2*!!(condition)]))
+#define BUG_ON(condition)      assert(!(condition))
 
 #define DIE_IF(cnd)                                            \
 do {                                                           \
index b4179424013c5663458b020f7d29908936bef6e1..5a5a331386d1fcd14310a7e67f759b6e46be1233 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/types.h>
 
 #include <stdbool.h>
-#include <assert.h>
 #include <limits.h>
 #include <stdlib.h>
 #include <stdio.h>
index 604dce49eddc84a039db1e6fc253f04362a500f1..2520b08847e8d7a5cb17882c05c216421747a29e 100644 (file)
@@ -2,8 +2,6 @@
 #include <string.h>
 #include <errno.h>
 
-#include <assert.h>
-
 /* user defined header files */
 #include "kvm/builtin-debug.h"
 #include "kvm/builtin-pause.h"
@@ -71,14 +69,14 @@ int handle_command(struct cmd_struct *command, int argc, const char **argv)
 
        if (!argv || !*argv) {
                p = kvm_get_command(command, "help");
-               assert(p);
+               BUG_ON(!p);
                return p->fn(argc, argv, prefix);
        }
 
        p = kvm_get_command(command, argv[0]);
        if (!p) {
                p = kvm_get_command(command, "help");
-               assert(p);
+               BUG_ON(!p);
                p->fn(0, NULL, prefix);
                return EINVAL;
        }
index 8c9e268012dfc7444354b14184610cfbf03eccbf..a60b11d0eb979648e1043bfe63bb88bbe2cf5c6d 100644 (file)
@@ -14,7 +14,6 @@
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <stdbool.h>
-#include <assert.h>
 #include <limits.h>
 #include <signal.h>
 #include <stdarg.h>
index 06eea0f674bdb7654f530efcd9294133ddd09216..41c40852d91c4e2d68d6496945158bfbf629558e 100644 (file)
@@ -3,8 +3,6 @@
 #include "kvm/util.h"
 #include "kvm/kvm.h"
 
-#include <assert.h>
-
 #define PCI_BAR_OFFSET(b)              (offsetof(struct pci_device_header, bar[b]))
 
 static struct pci_device_header                *pci_devices[PCI_MAX_DEVICES];
@@ -170,13 +168,13 @@ void pci__config_rd(struct kvm *kvm, union pci_config_address addr, void *data,
 
 void pci__register(struct pci_device_header *dev, u8 dev_num)
 {
-       assert(dev_num < PCI_MAX_DEVICES);
+       BUG_ON(dev_num >= PCI_MAX_DEVICES);
        pci_devices[dev_num]    = dev;
 }
 
 struct pci_device_header *pci__find_dev(u8 dev_num)
 {
-       assert(dev_num < PCI_MAX_DEVICES);
+       BUG_ON(dev_num >= PCI_MAX_DEVICES);
        return pci_devices[dev_num];
 }
 
index f838a8f255beb2cdd652ac45ecf31df417ca6ea5..d107de6d843368865053b163378448513ff9fe99 100644 (file)
@@ -17,7 +17,6 @@
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <stdbool.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
index 68c30f519d77b87df489b0137206b0240dc2474b..245cebb72edd9b35cf682ed598e63a2cfb37ae4c 100644 (file)
@@ -21,7 +21,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <termios.h>
-#include <assert.h>
 #include <unistd.h>
 #include <fcntl.h>
 
@@ -136,7 +135,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
        struct virt_queue *queue;
        void *p;
 
-       assert(vq < VIRTIO_CONSOLE_NUM_QUEUES);
+       BUG_ON(vq >= VIRTIO_CONSOLE_NUM_QUEUES);
 
        compat__remove_message(compat_id);
 
index bb97a7edbd4f7fa1c8b86efcdc6102884e57b8b1..5e297089f09376609d772dc29a6c89fecc4f4a1f 100644 (file)
@@ -19,7 +19,6 @@
 #include <net/if.h>
 
 #include <unistd.h>
-#include <assert.h>
 #include <fcntl.h>
 
 #include <sys/socket.h>
index ded07176191cb3e85fcaa052379a994c8aad37d3..0d1b1e311822e5ab1267261212d37b9c8f87cda7 100644 (file)
@@ -98,7 +98,7 @@ static void e820_setup(struct kvm *kvm)
                };
        }
 
-       BUILD_BUG_ON(i > E820_X_MAX);
+       BUG_ON(i > E820_X_MAX);
 
        e820->nr_map = i;
 }
index 644f37f309829e0a904fb36ee68974bec1e8383a..75f3b4d2e7f32533b62ae0d5bf8158527d8b51f8 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <sys/ioctl.h>
 #include <stdlib.h>
-#include <assert.h>
 
 #define CPUID_FUNC_PERFMON             0x0A
 
index d2fbbe2be18704c99f5f400b2f7b14e752a242a6..129c4ff9fcce9d4b26fdf56b062fe72f9455ba27 100644 (file)
@@ -15,7 +15,6 @@
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <stdbool.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>