efile_drv: logic error in compressed file write
efile_drv: logic error in compressed file write

Compiling OTP 18.2.1 with gcc-5.3 shows the following warning:

drivers/common/efile_drv.c:1538:23: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]

The code in question is:

        if (! (status =
               erts_gzwrite((ErtsGzFile)d->fd,
                            iov[i].iov_base,
                            iov[i].iov_len)) == iov[i].iov_len) {
            d->errInfo.posix_errno =
                d->errInfo.os_errno = errno; /* XXX Correct? */
            break;
        }

If we hoist the assignment out of the if for clarity, it becomes:

        status = erts_gzwrite(..., iov[i].iov_len);
        if (! status == iov[i].iov_len) { ...; break; }

iov_len is > 0 here, and status will equal iov_len if erts_gzwrite
succeeded, but will be less than iov_len if an error occurred.

"! status" is 0 or 1, which can only equal iov_len if iov_len is 1 and
erts_gzwrite detected an error and returned 0.

The effect of this mistake is that any error when iov_len >= 2 will
skip the conditional code and break statement.  In particular, partial
writes (0 < status && status < iov_len) will not be flagged as errors.

All releases since OTP R8B-0 are affected.

The variable "status" is really a boolean, which is to be set to zero
on error.  The fix is to set status to 1 if erts_gzwrite() returned iov_len
and 0 otherwise, and to change the condition to "if (! status) ...".

I'm also hoisting the assignment out of the condition since it obscures
the code while providing not benefit (the condition in a while or for
loop would be a different matter).

aboroska/otp,rlipscombe/otp,goertzenator/otp,dumbbell/otp,hairyhum/otp,ferd/otp,isvilen/otp,uabboli/otp,lightcyphers/otp,falkevik/otp,release-project/otp,isvilen/otp,msantos/otp,potatosalad/otp,release-project/otp,vinoski/otp,bjorng/otp,fenollp/otp,rlipscombe/otp,bsmr-erlang/otp,fenollp/otp,neeraj9/otp,neeraj9/otp,cobusc/otp,ahmedshafeeq/otp,dgud/otp,matwey/otp,dumbbell/otp,bjorng/otp,derek121/otp,legoscia/otp,g-andrade/otp,weisslj/otp,RoadRunnr/otp,saleyn/otp,msantos/otp,bjorng/otp,aboroska/otp,bugs-erlang-org/otp,fenollp/otp,ahmedshafeeq/otp,release-project/otp,mikpe/otp,saleyn/otp,getong/otp,bsmr-erlang/otp,weisslj/otp,release-project/otp,dgud/otp,erlang/otp,saleyn/otp,dumbbell/otp,kvakvs/otp,derek121/otp,tuncer/otp,fenollp/otp,isvilen/otp,ahmedshafeeq/otp,bjorng/otp,psyeugenic/otp,g-andrade/otp,dumbbell/otp,vladdu/otp,fenollp/otp,g-andrade/otp,g-andrade/otp,emile/otp,dumbbell/otp,uabboli/otp,bugs-erlang-org/otp,RaimoNiskanen/otp,johanclaesson/otp,weisslj/otp,lightcyphers/otp,ferd/otp,massemanet/otp,legoscia/otp,erlang/otp,lightcyphers/otp,goertzenator/otp,bsmr-erlang/otp,goertzenator/otp,ferd/otp,matwey/otp,psyeugenic/otp,vinoski/otp,falkevik/otp,RoadRunnr/otp,erlang/otp,RaimoNiskanen/otp,basho/otp,uabboli/otp,bernardd/otp,jj1bdx/otp,lrascao/otp,RoadRunnr/otp,emacsmirror/erlang,getong/otp,bernardd/otp,bernardd/otp,tuncer/otp,basho/otp,getong/otp,lightcyphers/otp,RoadRunnr/otp,rlipscombe/otp,vladdu/otp,RaimoNiskanen/otp,johanclaesson/otp,neeraj9/otp,bugs-erlang-org/otp,g-andrade/otp,emile/otp,kvakvs/otp,getong/otp,emacsmirror/erlang,bsmr-erlang/otp,cobusc/otp,erlang/otp,vladdu/otp,isvilen/otp,rlipscombe/otp,potatosalad/otp,RaimoNiskanen/otp,g-andrade/otp,potatosalad/otp,bsmr-erlang/otp,mikpe/otp,falkevik/otp,potatosalad/otp,release-project/otp,bernardd/otp,msantos/otp,kvakvs/otp,dgud/otp,ferd/otp,fenollp/otp,kvakvs/otp,emacsmirror/erlang,bjorng/otp,fenollp/otp,vinoski/otp,bjorng/otp,dgud/otp,emile/otp,lrascao/otp,hairyhum/otp,legoscia/otp,ferd/otp,electricimp/otp,lemenkov/otp,bugs-erlang-org/otp,emile/otp,vladdu/otp,RoadRunnr/otp,emacsmirror/erlang,basho/otp,g-andrade/otp,goertzenator/otp,getong/otp,lemenkov/otp,tuncer/otp,lrascao/otp,mikpe/otp,derek121/otp,psyeugenic/otp,fenollp/otp,legoscia/otp,ferd/otp,lightcyphers/otp,getong/otp,psyeugenic/otp,jj1bdx/otp,lemenkov/otp,electricimp/otp,release-project/otp,RaimoNiskanen/otp,ahmedshafeeq/otp,ahmedshafeeq/otp,vladdu/otp,ferd/otp,dgud/otp,ferd/otp,lightcyphers/otp,vinoski/otp,tuncer/otp,release-project/otp,rlipscombe/otp,mikpe/otp,aboroska/otp,bugs-erlang-org/otp,legoscia/otp,erlang/otp,erlang/otp,kvakvs/otp,saleyn/otp,bjorng/otp,lemenkov/otp,release-project/otp,basho/otp,johanclaesson/otp,emile/otp,bernardd/otp,msantos/otp,saleyn/otp,vinoski/otp,potatosalad/otp,potatosalad/otp,g-andrade/otp,isvilen/otp,lightcyphers/otp,electricimp/otp,goertzenator/otp,kvakvs/otp,bsmr-erlang/otp,saleyn/otp,bugs-erlang-org/otp,cobusc/otp,aboroska/otp,cobusc/otp,hairyhum/otp,electricimp/otp,uabboli/otp,mikpe/otp,lrascao/otp,weisslj/otp,hairyhum/otp,hairyhum/otp,RaimoNiskanen/otp,legoscia/otp,bernardd/otp,lrascao/otp,vinoski/otp,bernardd/otp,uabboli/otp,electricimp/otp,getong/otp,matwey/otp,falkevik/otp,basho/otp,basho/otp,derek121/otp,massemanet/otp,basho/otp,cobusc/otp,matwey/otp,mikpe/otp,aboroska/otp,electricimp/otp,dumbbell/otp,dgud/otp,emile/otp,emacsmirror/erlang,falkevik/otp,RoadRunnr/otp,psyeugenic/otp,vladdu/otp,jj1bdx/otp,falkevik/otp,massemanet/otp,vladdu/otp,massemanet/otp,psyeugenic/otp,tuncer/otp,kvakvs/otp,mikpe/otp,lemenkov/otp,aboroska/otp,g-andrade/otp,saleyn/otp,potatosalad/otp,matwey/otp,goertzenator/otp,bjorng/otp,neeraj9/otp,RaimoNiskanen/otp,aboroska/otp,RaimoNiskanen/otp,erlang/otp,matwey/otp,emile/otp,cobusc/otp,emile/otp,basho/otp,getong/otp,kvakvs/otp,derek121/otp,erlang/otp,isvilen/otp,dumbbell/otp,bjorng/otp,dumbbell/otp,bsmr-erlang/otp,lemenkov/otp,matwey/otp,johanclaesson/otp,matwey/otp,emacsmirror/erlang,mikpe/otp,lrascao/otp,emacsmirror/erlang,ahmedshafeeq/otp,dgud/otp,goertzenator/otp,ferd/otp,lrascao/otp,rlipscombe/otp,isvilen/otp,rlipscombe/otp,mikpe/otp,dgud/otp,basho/otp,rlipscombe/otp,hairyhum/otp,isvilen/otp,RoadRunnr/otp,lrascao/otp,neeraj9/otp,jj1bdx/otp,msantos/otp,emacsmirror/erlang,massemanet/otp,jj1bdx/otp,hairyhum/otp,emacsmirror/erlang,jj1bdx/otp,electricimp/otp,fenollp/otp,kvakvs/otp,rlipscombe/otp,weisslj/otp,cobusc/otp,potatosalad/otp,tuncer/otp,tuncer/otp,cobusc/otp,ahmedshafeeq/otp,isvilen/otp,lightcyphers/otp,potatosalad/otp,dgud/otp,weisslj/otp,johanclaesson/otp,uabboli/otp,vinoski/otp,weisslj/otp,weisslj/otp,jj1bdx/otp,mikpe/otp,bernardd/otp,isvilen/otp,bugs-erlang-org/otp,vladdu/otp,uabboli/otp,lemenkov/otp,bugs-erlang-org/otp,release-project/otp,vinoski/otp,johanclaesson/otp,msantos/otp,rlipscombe/otp,lrascao/otp,hairyhum/otp,vinoski/otp,ahmedshafeeq/otp,matwey/otp,electricimp/otp,RoadRunnr/otp,getong/otp,electricimp/otp,neeraj9/otp,erlang/otp,emile/otp,massemanet/otp,falkevik/otp,massemanet/otp,derek121/otp,legoscia/otp,bernardd/otp,getong/otp,derek121/otp,bsmr-erlang/otp,massemanet/otp,neeraj9/otp,derek121/otp,weisslj/otp,johanclaesson/otp,neeraj9/otp,dumbbell/otp,bjorng/otp,jj1bdx/otp,psyeugenic/otp,vinoski/otp,jj1bdx/otp,dgud/otp,psyeugenic/otp,vladdu/otp,bsmr-erlang/otp,legoscia/otp,uabboli/otp,emacsmirror/erlang,goertzenator/otp,RaimoNiskanen/otp,tuncer/otp,massemanet/otp,erlang/otp,tuncer/otp,saleyn/otp,uabboli/otp,ahmedshafeeq/otp,legoscia/otp,aboroska/otp,RoadRunnr/otp,falkevik/otp,saleyn/otp,jj1bdx/otp,johanclaesson/otp,falkevik/otp,g-andrade/otp,msantos/otp,lemenkov/otp,dumbbell/otp,goertzenator/otp,msantos/otp,aboroska/otp,potatosalad/otp