summarylogtreecommitdiffstats
path: root/gq-1.3.4-errorchain.patch
blob: fcacdd2ff1e8e7664b2f3371a17dd4302c649bd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
commit 58ce4cd00705dd15ba2f509a00c0c58490489f32
Author: Terje Røsten <terje.rosten@ntnu.no>
Date:   Mon Nov 18 20:41:36 2013 +0100

    fix too creative hackery

diff --git a/src/errorchain.c b/src/errorchain.c
index fc3092d..84dae81 100644
--- a/src/errorchain.c
+++ b/src/errorchain.c
@@ -110,34 +110,13 @@ error_push_production_v(int         context,
 {
      struct errchain *chain;
      GString *str;
-     int n, a, retry = 0;
 
 	if(!context) {
 		return;
 	}
 
-     a = strlen(fmt) + 50;
-	str = g_string_sized_new(a);
-#warning "FIXME: this is so sick"
-
-     /* I hope it is ok to repeatedly use ap like this */
-     do {
-	  n = g_vsnprintf(str->str, a - 1, fmt, ap);
-
-	  retry = 0;
-	  /* await both n==-1 and n > a -1 for not enough free space */
-	  if (n > a - 1) {
-	       g_string_free(str, TRUE);
-	       a = n + 2;
-	       str = g_string_sized_new(a);
-	       retry = 1;
-	  } else if (n == -1) {
-	       g_string_free(str, TRUE);
-	       a *= 2;
-	       str = g_string_sized_new(a);
-	       retry = 1;
-	  }
-     } while (retry);
+     str = g_string_sized_new(100);
+     g_string_vprintf(str, fmt, ap);
 
      /* plug into messagechain */
      chain = error_chain_by_context(context);