Thread (88 messages) 88 messages, 13 authors, 2017-10-23

RE: char-TPM: Adjustments for ten function implementations

From: <hidden>
Date: 2017-10-18 10:44:13
Also in: kernel-janitors, linux-integrity, lkml

On Wed, 18 Oct 2017, Alexander.Steffen@infineon.com wrote:
=20
quoted
quoted
On Wed, 2017-10-18 at 11:00 +0200, SF Markus Elfring wrote:
quoted
quoted
The printk removals do change the objects.

The value of that type of change is only for resource limited sys=
tems.
quoted
quoted
quoted
I imagine that such small code adjustments are also useful for othe=
r
quoted
quoted
systems.

Your imagination and mine differ.
Where do you _think_ it matters?

For instance, nothing about

	sizeof(type)
vs
	sizeof(*ptr)

makes it easier for a human to read the code.
If it does not make it easier to read the code for you, then maybe you
should consider that this might not be true for all humans. For me, it
makes it much easier to see at a glance, that code like
ptr=3Dmalloc(sizeof(*ptr)) is correct.
=20
I don't think there is a perfect solution.
Maybe. But for the second variant the correctness is easier to check, both =
mentally and programmatically, because there is no need for any context (th=
e type of ptr does not matter).
The type argument to sizeof
could have the wrong type.  The expression argument to sizeof could be
missing the *.  Unpleasant consequences are possible in both cases.
Probably each maintainer has a style they prefer.  Perhaps it could be
useful to adjust the code to follow the dominant strategy, in cases where
there are a inconsistencies.
Certainly. At least within a file, there should be only one style.
For example
=20
if (...)
  x =3D foo1(sizeof(struct xtype));
else
  x =3D foo2(sizeof(*x));
=20
might at least cause some unnecessary mental effort to process.
=20
julia
Alexander
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help