bug-hurd
[Top][All Lists]
Advanced

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

Re: [PATCH 1/8] kern: fix printing of kmem_cache names


From: Justus Winter
Subject: Re: [PATCH 1/8] kern: fix printing of kmem_cache names
Date: Sat, 01 Feb 2014 16:34:20 +0100
User-agent: alot/0.3.4

Quoting Samuel Thibault (2014-02-01 15:20:55)
> Justus Winter, le Sat 01 Feb 2014 15:09:21 +0100, a écrit :
> > The name field is not necessarily zero-terminated.  Use a precision
> > argument to limit the number of characters written when printing the
> > name.
> 
> Mmm, I'd probably rather see the name field always be zero-terminated,
> since that's just one place, vs the various places which would want to
> print it.

I thought about doing that.  But that would waste one character just
for the termination.

I see the name fields as a useful kind of padding.  If the amount of
padding needed for some alignment requirement is low, say eight bytes,
this could make a difference.

GNU Machs printf implementation supports strings with the precision
given as argument:

  printf ("%.*s", sizeof foo->name, foo->name);

I think thats clean, concise and easy to use.

I also kind of like the idea of explicitly bounding string operations
in the kernel.  And from what I've seen, there isn't that much string
handling in the core of the kernel.

Not zero-terminating these fields also brings the golden opportunity
to fill them with non-zero values and see whether stuff breaks :p

Justus



reply via email to

[Prev in Thread] Current Thread [Next in Thread]