Mail Archives: djgpp-workers/2012/12/04/16:49:30
Am 04.12.2012 21:25, schrieb Eli Zaretskii:
>> Date: Tue, 4 Dec 2012 22:11:30 +0200
>> From: Ozkan Sezer <sezeroz AT gmail DOT com>
>>
>>> Why is it better to do this:
>>>
>>> inst = unassemble_proper (j, &len);
>>> (void) inst; /* set, but not used. */
>>>
>>> instead of this:
>>>
>>> unassemble_proper (j, &len);
>>>
>>> Is it "verboten" to discard the return value of a function, for some
>>> reason? Some exciting new "feature" of the latest GCC versions or
>>> something?
>>>
>> I kept the unused var only because it is referenced in the if 0'ed
>> out block. Otherwise, yours is just fine too. If your version is to
>> be preferred, then it is advisable to remove that if 0'ed out block
>> as well.
> IMO, if we want to ignore the return value, let's do that in the most
> natural way, which is not assign it to any variable. Like we do with
> printf, for example, when we don't need its return value.
>
A new patch ignoring the return value of the function.
diff -aprNU5 djgpp.orig/src/debug/fsdb/fullscr.c djgpp/src/debug/fsdb/fullscr.c
--- djgpp.orig/src/debug/fsdb/fullscr.c 2012-12-01 04:29:46 +0000
+++ djgpp/src/debug/fsdb/fullscr.c 2012-12-04 22:21:24 +0000
@@ -855,11 +855,11 @@ select_source_file (char *file)
static int
code_skip (int origin, int count)
{
int len, *next, i, j, k, instcount, done, leave;
- char *state, *source /* , *inst */;
+ char *state, *source;
if (count >= 0)
{
while (count-- > 0)
if (valid_instaddr (origin))
@@ -887,13 +887,11 @@ code_skip (int origin, int count)
{
done++;
j = origin - done;
if (valid_instaddr (j))
{
-#if 0
- inst = unassemble_proper (j, &len);
-#endif
+ unassemble_proper (j, &len);
source = unassemble_source (j);
next[done] = j + len;
if (source)
{
leave = 0;
@@ -907,13 +905,13 @@ code_skip (int origin, int count)
code we don't need this. */
#if 0
leave = (strncmp (inst, "jmp", 3) == 0
|| strncmp (inst, "ret", 3) == 0
|| strncmp (inst, "iret", 4) == 0);
- if (!leave)
- inst = unassemble_proper (j, &len);
#endif
+ if (!leave)
+ unassemble_proper (j, &len);
}
}
}
else
{
- Raw text -