[RFC PATCH v3] Refactor to avoid nonnull checks on "this" pointer.

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Apr 1 16:24:00 GMT 2016


On Apr  1 11:42, Peter Foley wrote:
> G++ 6.0 asserts that the "this" pointer is non-null for member
> functions.
> Refactor methods that check if this is non-null to resolve this.
> 
> Signed-off-by: Peter Foley <pefoley2@pefoley.com>
> ---
> Just wanted to make sure that this approach looked good before I fix
> all the problematic files.

Looks good to me, except for a style issue:

> -	audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
> -	debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
> -		      buf, p->fragments, p->fragsize, p->bytes);
> +        if (audio_out_) {
> +            audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
> +        } else {
> +            Audio_out::default_buf_info(p, audiofreq_, audiobits_, audiochannels_);
> +        }

I guess this was just a result of speed-typing :) but that should be

  if (audio_out_)
    {
      ...
    }
  else
    {
      ...
    }

OTOH, single-line statements shouldn't use braces at all:

   if (audio_out_)
     audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
   else
     Audio_out::default_buf_info(p, audiofreq_, audiobits_, audiochannels_);

Other than that, please go ahead.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20160401/e9f19a47/attachment.sig>


More information about the Cygwin-patches mailing list