This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]