]> git.proxmox.com Git - qemu.git/blobdiff - qemu-error.c
softfloat: Drop [s]bits{8, 16, 32, 64} types in favor of [u]int{8, 16, 32, 64}_t
[qemu.git] / qemu-error.c
index 23176e16a8fe770b0d006ea1d50e707fb14c224e..5a35e7c1c2c0f9fa63fcf4bccba8a804af09619c 100644 (file)
@@ -41,6 +41,17 @@ void error_printf(const char *fmt, ...)
     va_end(ap);
 }
 
+void error_printf_unless_qmp(const char *fmt, ...)
+{
+    va_list ap;
+
+    if (!monitor_cur_is_qmp()) {
+        va_start(ap, fmt);
+        error_vprintf(fmt, ap);
+        va_end(ap);
+    }
+}
+
 static Location std_loc = {
     .kind = LOC_NONE
 };
@@ -113,6 +124,16 @@ void loc_set_none(void)
     cur_loc->kind = LOC_NONE;
 }
 
+/*
+ * Change the current location to argument ARGV[IDX..IDX+CNT-1].
+ */
+void loc_set_cmdline(char **argv, int idx, int cnt)
+{
+    cur_loc->kind = LOC_CMDLINE;
+    cur_loc->num = cnt;
+    cur_loc->ptr = argv + idx;
+}
+
 /*
  * Change the current location to file FNAME, line LNO.
  */
@@ -143,12 +164,22 @@ void error_set_progname(const char *argv0)
 void error_print_loc(void)
 {
     const char *sep = "";
+    int i;
+    const char *const *argp;
 
-    if (!cur_mon) {
+    if (!cur_mon && progname) {
         fprintf(stderr, "%s:", progname);
         sep = " ";
     }
     switch (cur_loc->kind) {
+    case LOC_CMDLINE:
+        argp = cur_loc->ptr;
+        for (i = 0; i < cur_loc->num; i++) {
+            error_printf("%s%s", sep, argp[i]);
+            sep = " ";
+        }
+        error_printf(": ");
+        break;
     case LOC_FILE:
         error_printf("%s:", (const char *)cur_loc->ptr);
         if (cur_loc->num) {
@@ -157,7 +188,7 @@ void error_print_loc(void)
         error_printf(" ");
         break;
     default:
-        error_printf(sep);
+        error_printf("%s", sep);
     }
 }
 
@@ -176,21 +207,3 @@ void error_report(const char *fmt, ...)
     va_end(ap);
     error_printf("\n");
 }
-
-void qerror_report_internal(const char *file, int linenr, const char *func,
-                            const char *fmt, ...)
-{
-    va_list va;
-    QError *qerror;
-
-    va_start(va, fmt);
-    qerror = qerror_from_info(file, linenr, func, fmt, &va);
-    va_end(va);
-
-    if (cur_mon) {
-        monitor_set_error(cur_mon, qerror);
-    } else {
-        qerror_print(qerror);
-        QDECREF(qerror);
-    }
-}