This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][sh] Fix iov[] size in register_dump()


Hi,

Kaz Kojima <kkojima@rr.iij4u.or.jp> wrote:
> The copyright years should be updated.  Looks OK to me
Added.

Andreas Schwab <schwab@redhat.com> wrote:
> Magic numbers are bad.
Right.
I think, using more magic numbers might looks less magical.
+  struct iovec iov[22*2 + 34*2 + 2];

Because the size comes rather from the display format, than register set
(that was the cause of this error), another idea is setting it size by
format, like
| #define IOV_STRING(str) { .iov_base = (char *)str, .iov_len = strlen(str) }
|  struct iovec iov[] = {
|    IOV_STRING("Register dump:\n\n  R0: "), {regs[0], 8},
|    ...
but, I think it is a bit too big change.
Are there any idea to know the size (hopefully, statically)?

Cheers,
/yoshii


2010-05-26  Takashi Yoshii  <takashi.yoshii.zj@renesas.com>

	* sysdeps/unix/sysv/linux/sh/sh4/register-dump.h: Fix iov[] size.

---
diff --git a/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h b/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h
index e3c9c0e..437a76c 100644
--- a/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h
+++ b/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h
@@ -1,5 +1,5 @@
 /* Dump registers.
-   Copyright (C) 1999, 2000, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2009, 2010 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -58,7 +58,7 @@ register_dump (int fd, struct sigcontext *ctx)
 {
   char regs[22][8];
   char fpregs[34][8];
-  struct iovec iov[112];
+  struct iovec iov[22*2 + 34*2 + 2];
   size_t nr = 0;
 
 #define ADD_STRING(str) \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]