[Asterisk-code-review] cleanup: Fix fread() and fwrite() error handling (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Tue Apr 25 16:13:15 CDT 2017


Richard Mudgett has posted comments on this change. ( https://gerrit.asterisk.org/5510 )

Change subject: cleanup: Fix fread() and fwrite() error handling
......................................................................


Patch Set 2:

(1 comment)

https://gerrit.asterisk.org/#/c/5510/2/apps/app_minivm.c
File apps/app_minivm.c:

PS2, Line 859: 	if ((l = fread(bio->iobuf, 1, B64_BASEMAXINLINE, fi)) != B64_BASEMAXINLINE) {
             : 		if (ferror(fi))
             : 			return -1;
             : 
             : 		bio->ateof = 1;
             : 		return 0;
             : 	}
> > This function is rather stupid when handling short reads.
We don't care between a read error and eof.  The code returning -1 is wrong for the caller since the caller only cares about zero and nonzero.  When zero it is eof.  When non-zero it got data and expects to pull it out of the buffer.  It is weird that the code is doing double buffering since FILE is buffered IO.


-- 
To view, visit https://gerrit.asterisk.org/5510
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I8ca1cd47c20b2c0b72088bd13b9046f6977aa872
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-HasComments: Yes



More information about the asterisk-code-review mailing list