[RFA] gdbserver/server.c: Replace 2x strlen() by a variable
Joel Brobecker
brobecker@adacore.com
Thu Dec 21 11:08:00 GMT 2006
> ChangeLog:
>
> * server.c (handle_general_set): New variable len instead
> of using strlen two times.
Actually, since the same string is duplicated a couple of times,
I would also suggest declaring a constant string "QPassSignals:"
and use the constant instead of risking a typo... How about:
const char str[] = "QPassSignals:";
and then use "sizeof (str) - 1". Is that bad coding style? Otherwise,
you can declare your sale constant:
const int len = strlen (str);
I am not reviewer, so these are just suggestions, not a request (JIC).
> =========================================
> diff -urN src/gdb/gdbserver/server.c dev/gdb/gdbserver/server.c
> --- src/gdb/gdbserver/server.c 2006-12-21 08:38:11.000000000 +0100
> +++ dev/gdb/gdbserver/server.c 2006-12-21 08:38:25.000000000 +0100
> @@ -163,10 +163,11 @@
> void
> handle_general_set (char *own_buf)
> {
> - if (strncmp ("QPassSignals:", own_buf, strlen ("QPassSignals:")) == 0)
> + int len = strlen ("QPassSignals:");
> + if (strncmp ("QPassSignals:", own_buf, len) == 0)
> {
> int numsigs = (int) TARGET_SIGNAL_LAST, i;
> - const char *p = own_buf + strlen ("QPassSignals:");
> + const char *p = own_buf + len;
> CORE_ADDR cursig;
>
> p = decode_address_to_semicolon (&cursig, p);
>
> Regards,
> Markus
>
> --
> Markus Deuling
> GNU Toolchain for Linux on Cell BE
> deuling@de.ibm.com
--
Joel
More information about the Gdb-patches
mailing list