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

Re: [libvirt PATCH 05/14] Remove pointless initializations



On Thu, Sep 24, 2020 at 10:30:21AM +0200, Martin Kletzander wrote:
> On Wed, Sep 23, 2020 at 08:14:54PM +0200, Ján Tomko wrote:
> > Signed-off-by: Ján Tomko <jtomko redhat com>
> > ---
> > src/test/test_driver.c | 2 +-
> > tests/virnumamock.c    | 2 +-
> > tests/virrandommock.c  | 2 +-
> > 3 files changed, 3 insertions(+), 3 deletions(-)
> > 
> 
> As mentioned in the previous patch I do not think they are pointless in the long
> run.  I prefer ret, rc, rv and similar to be initialised to error/negative value
> and others to their null values (numbers to zero, pointers to NULL etc.) even
> though I know this is a very subjective opinion.

Yeah, I tend to agree. From a defensive coding POV it is preferrable to
initialize every single variable at time of declaration to a known value.

While compilers and coverity can check for use of uninitialized variables,
I don't think their checks have ever been perfect, because new versions of
compilers tend to discover things periodically.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


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