Line 0
Link Here
|
|
|
1 |
1. Replaced int with uint64_t to avoid truncating pointer to (32bit) |
2 |
int by using a wider type. |
3 |
2. Replaced pointer to int type cast with a macro PTR_TO_UINT64(x) to |
4 |
help convert the pointer to uint64_t. |
5 |
|
6 |
This prevents the segfault on startup in amd64 systems. |
7 |
|
8 |
--- src/tree_misc.c.orig 2003-03-14 00:31:02 UTC |
9 |
+++ src/tree_misc.c |
10 |
@@ -27,12 +27,12 @@ |
11 |
#include "ui_cli.h" |
12 |
#include "evilloop.h" |
13 |
|
14 |
-static int cmd_movenode (int argc, char **argv, void *data) |
15 |
+static uint64_t cmd_movenode (int argc, char **argv, void *data) |
16 |
{ |
17 |
Node *pos = (Node *) data; |
18 |
if(argc<2){ |
19 |
cli_outfunf("usage: %s <left|right|up|down>",argv[0]); |
20 |
- return (int)pos; |
21 |
+ return PTR_TO_UINT64(pos); |
22 |
} |
23 |
if (!strcmp (argv[1], "left")) { |
24 |
if (node_left (pos)) { |
25 |
@@ -64,7 +64,7 @@ static int cmd_movenode (int argc, char **argv, void * |
26 |
node_swap (pos, node_down (pos)); |
27 |
} |
28 |
} |
29 |
- return (int) pos; |
30 |
+ return PTR_TO_UINT64(pos); |
31 |
} |
32 |
|
33 |
/* |
34 |
@@ -75,12 +75,12 @@ void init_movenode () |
35 |
cli_add_command ("movenode", cmd_movenode, "<up|left|right|down>"); |
36 |
} |
37 |
|
38 |
-static int cmd_go(int argc, char **argv, void *data){ |
39 |
+static uint64_t cmd_go(int argc, char **argv, void *data){ |
40 |
Node *pos=(Node *)data; |
41 |
|
42 |
if(argc!=2){ |
43 |
cli_outfunf("usage: %s <up|down|left|right|recurse|backrecurse|root|top|bottom>"); |
44 |
- return (int)pos; |
45 |
+ return PTR_TO_UINT64(pos); |
46 |
} |
47 |
|
48 |
if(!strcmp(argv[1],"up")){ |
49 |
@@ -110,7 +110,7 @@ static int cmd_go(int argc, char **argv, void *data){ |
50 |
} |
51 |
|
52 |
|
53 |
- return (int)pos; |
54 |
+ return PTR_TO_UINT64(pos); |
55 |
} |
56 |
|
57 |
/* |
58 |
@@ -126,7 +126,7 @@ void init_go () |
59 |
#include "ctype.h" |
60 |
#include "ui_binding.h" |
61 |
|
62 |
-static int cmd_outdent (int argc, char **argv, void *data) |
63 |
+static uint64_t cmd_outdent (int argc, char **argv, void *data) |
64 |
{ |
65 |
Node *pos = (Node *) data; |
66 |
|
67 |
@@ -135,7 +135,7 @@ static int cmd_outdent (int argc, char **argv, void *d |
68 |
inputbuf[strlen (inputbuf) + 1] = 0; |
69 |
inputbuf[strlen (inputbuf)] = lastbinding->key; |
70 |
} |
71 |
- return (int)pos; |
72 |
+ return PTR_TO_UINT64(pos); |
73 |
} |
74 |
|
75 |
if (node_left (pos)) { |
76 |
@@ -166,12 +166,12 @@ static int cmd_outdent (int argc, char **argv, void *d |
77 |
target_node->right = NULL; |
78 |
} |
79 |
} |
80 |
- return (int) pos; |
81 |
+ return PTR_TO_UINT64(pos); |
82 |
} |
83 |
|
84 |
/* FIXME: no real need for a temporary node */ |
85 |
|
86 |
-static int cmd_indent (int argc, char **argv, void *data) |
87 |
+static uint64_t cmd_indent (int argc, char **argv, void *data) |
88 |
{ |
89 |
Node *pos = (Node *) data; |
90 |
|
91 |
@@ -180,7 +180,7 @@ static int cmd_indent (int argc, char **argv, void *da |
92 |
inputbuf[strlen (inputbuf) + 1] = 0; |
93 |
inputbuf[strlen (inputbuf)] = lastbinding->key; |
94 |
} |
95 |
- return (int)pos; |
96 |
+ return PTR_TO_UINT64(pos); |
97 |
} |
98 |
|
99 |
if (node_up (pos)) { |
100 |
@@ -205,7 +205,7 @@ static int cmd_indent (int argc, char **argv, void *da |
101 |
} |
102 |
node_remove (node_down (pos)); |
103 |
} |
104 |
- return (int) pos; |
105 |
+ return PTR_TO_UINT64(pos); |
106 |
} |
107 |
|
108 |
/* |
109 |
@@ -221,7 +221,7 @@ void init_outdent_indent () |
110 |
"moves the active item and the following siblings one level to the right"); |
111 |
} |
112 |
|
113 |
-static int remove_cmd (int argc, char **argv, void *data) |
114 |
+static uint64_t remove_cmd (int argc, char **argv, void *data) |
115 |
{ |
116 |
Node *pos = (Node *) data; |
117 |
|
118 |
@@ -242,7 +242,7 @@ static int remove_cmd (int argc, char **argv, void *da |
119 |
docmd (pos, "save_state"); |
120 |
pos = node_remove (pos); |
121 |
} |
122 |
- return (int) pos; |
123 |
+ return PTR_TO_UINT64(pos); |
124 |
} |
125 |
|
126 |
/* |
127 |
@@ -256,7 +256,7 @@ void init_remove () |
128 |
} |
129 |
|
130 |
|
131 |
-static int commandline_cmd (int argc, char **argv, void *data) |
132 |
+static uint64_t commandline_cmd (int argc, char **argv, void *data) |
133 |
{ |
134 |
Node *pos = (Node *) data; |
135 |
|
136 |
@@ -271,7 +271,7 @@ static int commandline_cmd (int argc, char **argv, voi |
137 |
if (commandline[0]) |
138 |
pos = docmd (pos, commandline); |
139 |
} while (commandline[0] && strcmp(commandline,"q") && strcmp(commandline,"quit")); |
140 |
- return (int) pos; |
141 |
+ return PTR_TO_UINT64(pos); |
142 |
} |
143 |
|
144 |
/* |
145 |
@@ -284,7 +284,7 @@ void init_commandline () |
146 |
"Invokes the interactive commandline in curses mode."); |
147 |
} |
148 |
|
149 |
-static int insert_below_cmd (int argc, char **argv, void *data) |
150 |
+static uint64_t insert_below_cmd (int argc, char **argv, void *data) |
151 |
{ |
152 |
Node *pos = (Node *) data; |
153 |
|
154 |
@@ -299,7 +299,7 @@ static int insert_below_cmd (int argc, char **argv, vo |
155 |
} |
156 |
} |
157 |
inputbuf[0] = 0; |
158 |
- return (int) pos; |
159 |
+ return PTR_TO_UINT64(pos); |
160 |
} |
161 |
|
162 |
/* |