All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: Alon Levy <alevy@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] libcacard: remove useless initializers
Date: Sun, 11 May 2014 15:39:44 +0400	[thread overview]
Message-ID: <536F6180.1010905@msgid.tls.msk.ru> (raw)
In-Reply-To: <536F2DC0.9080809@redhat.com>

11.05.2014 11:58, Alon Levy wrote:
> On 05/08/2014 08:19 PM, Michael Tokarev wrote:
>> libcacard has many functions which initializes local variables
>> at declaration time, which are always assigned some values later
>> (often right after declaration).  Clean up these initializers.
> 
> How is this an improvement? Doesn't the compiler ignore this anyhow?

Just less code.

To me, when I see something like

  Type *var = NULL;

in a function, it somehow "translates" to a construct like

  Type *found = NULL;

That is -- so this variable will be used either as an accumulator
or a search result, so that initial value is really important.

So when I see the same variable receives its initial value in
the next line, I start wondering what's missed in the code which
should be there.  Or why I don't read the code correctly.  Or
something like this.

So, basically, this is a cleanup patch just to avoid confusion,
it most likely not needed for current compiler who can figure
it out by its own.  And for consistency - why not initialize
other variables too?

Maybe that's just my old-scool mind works this way.

At any rate you can just ignore this patch.

Thanks,

/mjt


WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: Alon Levy <alevy@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] libcacard: remove useless initializers
Date: Sun, 11 May 2014 15:39:44 +0400	[thread overview]
Message-ID: <536F6180.1010905@msgid.tls.msk.ru> (raw)
In-Reply-To: <536F2DC0.9080809@redhat.com>

11.05.2014 11:58, Alon Levy wrote:
> On 05/08/2014 08:19 PM, Michael Tokarev wrote:
>> libcacard has many functions which initializes local variables
>> at declaration time, which are always assigned some values later
>> (often right after declaration).  Clean up these initializers.
> 
> How is this an improvement? Doesn't the compiler ignore this anyhow?

Just less code.

To me, when I see something like

  Type *var = NULL;

in a function, it somehow "translates" to a construct like

  Type *found = NULL;

That is -- so this variable will be used either as an accumulator
or a search result, so that initial value is really important.

So when I see the same variable receives its initial value in
the next line, I start wondering what's missed in the code which
should be there.  Or why I don't read the code correctly.  Or
something like this.

So, basically, this is a cleanup patch just to avoid confusion,
it most likely not needed for current compiler who can figure
it out by its own.  And for consistency - why not initialize
other variables too?

Maybe that's just my old-scool mind works this way.

At any rate you can just ignore this patch.

Thanks,

/mjt

  reply	other threads:[~2014-05-11 11:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08 17:19 [Qemu-trivial] [PATCH] libcacard: remove useless initializers Michael Tokarev
2014-05-08 17:19 ` [Qemu-devel] " Michael Tokarev
2014-05-11  7:58 ` [Qemu-trivial] " Alon Levy
2014-05-11  7:58   ` [Qemu-devel] " Alon Levy
2014-05-11 11:39   ` Michael Tokarev [this message]
2014-05-11 11:39     ` Michael Tokarev
2014-05-12  9:20     ` [Qemu-trivial] " Markus Armbruster
2014-05-12  9:20       ` Markus Armbruster
2014-05-23 20:59       ` [Qemu-trivial] " Michael Tokarev
2014-05-23 20:59         ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-05-25 10:14         ` [Qemu-trivial] [Qemu-devel] " Alon Levy
2014-05-25 10:14           ` [Qemu-devel] [Qemu-trivial] " Alon Levy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=536F6180.1010905@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=alevy@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.