* [PATCH] Use correct default for target functions that return pointer
@ 2014-01-07 20:38 Andreas Schwab
2014-01-07 21:07 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Schwab @ 2014-01-07 20:38 UTC (permalink / raw)
To: gdb-patches
It is wrong to use a function that returns an int as a placeholder for a
function that returns a pointer.
Andreas.
* target.c (return_null): Define.
(update_current_target): Use it instead of return_zero for
functions that return a pointer.
---
gdb/target.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/gdb/target.c b/gdb/target.c
index 65c7a7a..42a8741 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -64,6 +64,8 @@ static int return_one (void);
static int return_minus_one (void);
+static void *return_null (void);
+
void target_ignore (void);
static void target_command (char *, int);
@@ -806,10 +808,10 @@ update_current_target (void)
return_zero);
de_fault (to_extra_thread_info,
(char *(*) (struct thread_info *))
- return_zero);
+ return_null);
de_fault (to_thread_name,
(char *(*) (struct thread_info *))
- return_zero);
+ return_null);
de_fault (to_stop,
(void (*) (ptid_t))
target_ignore);
@@ -819,7 +821,7 @@ update_current_target (void)
tcomplain);
de_fault (to_pid_to_exec_file,
(char *(*) (int))
- return_zero);
+ return_null);
de_fault (to_async,
(void (*) (void (*) (enum inferior_event_type, void*), void*))
tcomplain);
@@ -918,7 +920,7 @@ update_current_target (void)
tcomplain);
de_fault (to_traceframe_info,
(struct traceframe_info * (*) (void))
- return_zero);
+ return_null);
de_fault (to_supports_evaluation_of_breakpoint_conditions,
(int (*) (void))
return_zero);
@@ -3634,6 +3636,12 @@ return_minus_one (void)
return -1;
}
+static void *
+return_null (void)
+{
+ return 0;
+}
+
/*
* Find the next target down the stack from the specified target.
*/
--
1.8.5.2
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Use correct default for target functions that return pointer
2014-01-07 20:38 [PATCH] Use correct default for target functions that return pointer Andreas Schwab
@ 2014-01-07 21:07 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2014-01-07 21:07 UTC (permalink / raw)
To: Andreas Schwab; +Cc: gdb-patches
>>>>> "Andreas" == Andreas Schwab <schwab@linux-m68k.org> writes:
Andreas> * target.c (return_null): Define.
Andreas> (update_current_target): Use it instead of return_zero for
Andreas> functions that return a pointer.
Ok.
FWIW I have a coming massive patch series that removes
nearly all uses of return_zero. After the series there are few enough
uses that we can make this code truly type-safe.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-07 21:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-07 20:38 [PATCH] Use correct default for target functions that return pointer Andreas Schwab
2014-01-07 21:07 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).