Refactor to avoid nonnull checks on "this" pointer.

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.

winsup/cygwin/ChangeLog:
external.cc (cygwin_internal): Check for a null pinfo before calling
cmdline.
fhandler_dsp.cc (Audio::blockSize): Make static.
fhandler_dsp.cc (Audio_in): add default_buf_info.
fhandler_dsp.cc (Audio_out): Ditto.
fhandler_dsp.cc (Audio_out::buf_info): Refactor method to call
default_buf_info if dev_ is null.
fhandler_dsp.cc (Audio_in::buf_info): Ditto.
fhandler_dsp.cc (fhandler_dev_dsp::_ioctl): Call Audio_out::default_buf_info if audio_out_ is null.
fhandler_dsp.cc (fhandler_dev_dsp::_ioctl): Call Audio_in::default_buf_info if audio_in_ is null.
fhandler_process.cc (format_process_fd): Check if pinfo is null.
fhandler_process.cc (format_process_root): Ditto.
fhandler_process.cc (format_process_cwd): Ditto.
fhandler_process.cc (format_process_cmdline): Ditto.
signal.cc (tty_min::kill_pgrp): Ditto.
signal.cc (_pinfo::kill0): Ditto.
sigproc.cc (pid_exists): Ditto.
sigproc.cc (remove_proc): Ditto.
times.cc (clock_gettime): Ditto.
times.cc (clock_getcpuclockid): Ditto.
path.cc (cwdstuff::override_win32_cwd): Check if old_cwd is null.
path.cc (fcwd_access_t::Free): Factor null check of "this" out to
caller(s).
pinfo.cc (_pinfo::exists): Ditto.
pinfo.cc (_pinfo::fd): Ditto.
pinfo.cc (_pinfo::fds): Ditto.
pinfo.cc (_pinfo::root): Ditto.
pinfo.cc (_pinfo::cwd): Ditto.
pinfo.cc (_pinfo::cmdline): Ditto.
signal.cc (_pinfo::kill): Ditto.
pinfo.cc (_pinfo::commune_request): remove non-null check on "this", as
this method is only called from pinfo.cc after null checks
pinfo.cc (_pinfo::pipe_fhandler): remove non-null check on "this", as
this method is only called from pipe.cc (fhandler_pipe::open) after a null check.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
This commit is contained in:
Peter Foley
2016-04-02 11:36:18 -04:00
committed by Corinna Vinschen
parent e7e6119241
commit 0008bdea02
9 changed files with 75 additions and 38 deletions

View File

@@ -514,7 +514,7 @@ _pinfo::set_ctty (fhandler_termios *fh, int flags)
bool __reg1
_pinfo::exists ()
{
return this && process_state && !(process_state & (PID_EXITED | PID_REAPED | PID_EXECED));
return process_state && !(process_state & (PID_EXITED | PID_REAPED | PID_EXECED));
}
bool
@@ -685,7 +685,7 @@ _pinfo::commune_request (__uint32_t code, ...)
res.s = NULL;
res.n = 0;
if (!this || !pid)
if (!pid)
{
set_errno (ESRCH);
goto err;
@@ -783,7 +783,7 @@ out:
fhandler_pipe *
_pinfo::pipe_fhandler (int64_t unique_id, size_t &n)
{
if (!this || !pid)
if (!pid)
return NULL;
if (pid == myself->pid)
return NULL;
@@ -796,7 +796,7 @@ char *
_pinfo::fd (int fd, size_t &n)
{
char *s;
if (!this || !pid)
if (!pid)
return NULL;
if (pid != myself->pid)
{
@@ -820,7 +820,7 @@ char *
_pinfo::fds (size_t &n)
{
char *s;
if (!this || !pid)
if (!pid)
return NULL;
if (pid != myself->pid)
{
@@ -848,7 +848,7 @@ char *
_pinfo::root (size_t& n)
{
char *s;
if (!this || !pid)
if (!pid)
return NULL;
if (pid != myself->pid && !ISSTATE (this, PID_NOTCYGWIN))
{
@@ -893,7 +893,7 @@ char *
_pinfo::cwd (size_t& n)
{
char *s = NULL;
if (!this || !pid)
if (!pid)
return NULL;
if (ISSTATE (this, PID_NOTCYGWIN))
{
@@ -939,7 +939,7 @@ char *
_pinfo::cmdline (size_t& n)
{
char *s = NULL;
if (!this || !pid)
if (!pid)
return NULL;
if (ISSTATE (this, PID_NOTCYGWIN))
{