Re: [PATCH] zl10353 and qt1010: fix stack corruption bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Em Wed, 17 Jun 2009 14:26:28 +0200
Matthias Schwarzott <zzam@xxxxxxxxxx> escreveu:

> On Mittwoch, 17. Juni 2009, Jan Nikitenko wrote:
> >
> > Or we could use sizeof, like this:
> >     char buf[sizeof("00: ") - 1 + 16 * (sizeof("00 ") - 1) + 1]
> > or
> >     char buf[sizeof("00: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
> > ")] but it is not very readable in my opinion either.
> >
> > Maybe the best way would be to avoid the need for temporal buffer
> > completely by directly using printk in a loop, that is only the first
> > printk with KERN_DEBUG, followed by sequence of printk with registers dump
> > and final printk with end of line (but isn't a printk without KERN_
> > facility coding style problem as well?).
> >
> 
> Exactly for this case, line continuation, there is KERN_CONT defined.

There are some functions meant for printing hex dumps at kernel.h:

extern void hex_dump_to_buffer(const void *buf, size_t len,
                                int rowsize, int groupsize,
                                char *linebuf, size_t linebuflen, bool ascii);
extern void print_hex_dump(const char *level, const char *prefix_str,
                                int prefix_type, int rowsize, int groupsize,
                                const void *buf, size_t len, bool ascii);
extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
                        const void *buf, size_t len);

Also, it is possible to use kasprintf() to dynamically allocate a temporary
buffer. If you use it, you'll need to do a kfree after its usage.



Cheers,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux