This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch#3 1/8] Code cleanup: reindent/trivial
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 3 Apr 2012 20:47:02 +0200
- Subject: [patch#3 1/8] Code cleanup: reindent/trivial
Hi,
this code is there since "Initial revision" and it is redundant, simplifed it.
while (1)
{
/* No 'break' here. */
p = strchr (p, DIRNAME_SEPARATOR);
if (p != 0)
++p;
else
break;
}
/* This conditional has to be always true. */
if (p == 0)
{
}
Thanks,
Jan
gdb/
2012-04-01 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup.
* source.c (add_path): Remove always true conditional 'p == 0' and
unindent its code block.
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -573,6 +573,7 @@ add_path (char *dirname, char **which_path, int parse_separators)
append:
{
unsigned int len = strlen (name);
+ char tinybuf[2];
p = *which_path;
while (1)
@@ -596,37 +597,33 @@ add_path (char *dirname, char **which_path, int parse_separators)
else
break;
}
- if (p == 0)
- {
- char tinybuf[2];
- tinybuf[0] = DIRNAME_SEPARATOR;
- tinybuf[1] = '\0';
+ tinybuf[0] = DIRNAME_SEPARATOR;
+ tinybuf[1] = '\0';
- /* If we have already tacked on a name(s) in this command,
- be sure they stay on the front as we tack on some
- more. */
- if (prefix)
- {
- char *temp, c;
-
- c = old[prefix];
- old[prefix] = '\0';
- temp = concat (old, tinybuf, name, (char *)NULL);
- old[prefix] = c;
- *which_path = concat (temp, "", &old[prefix], (char *) NULL);
- prefix = strlen (temp);
- xfree (temp);
- }
- else
- {
- *which_path = concat (name, (old[0] ? tinybuf : old),
- old, (char *)NULL);
- prefix = strlen (name);
- }
- xfree (old);
- old = *which_path;
+ /* If we have already tacked on a name(s) in this command,
+ be sure they stay on the front as we tack on some
+ more. */
+ if (prefix)
+ {
+ char *temp, c;
+
+ c = old[prefix];
+ old[prefix] = '\0';
+ temp = concat (old, tinybuf, name, (char *)NULL);
+ old[prefix] = c;
+ *which_path = concat (temp, "", &old[prefix], (char *) NULL);
+ prefix = strlen (temp);
+ xfree (temp);
+ }
+ else
+ {
+ *which_path = concat (name, (old[0] ? tinybuf : old),
+ old, (char *)NULL);
+ prefix = strlen (name);
}
+ xfree (old);
+ old = *which_path;
}
skip_dup:
;