com php-src: Fix bug #68711 Remove useless checks. 'num' is unsigned and cannot be <0.: ext/dba/libflatfile/flatfile.c
| From: | JulienPauli | Date: | Tue, 20 Jan 2015 13:54:48 +0000 |
| Subject: | com php-src: Fix bug #68711 Remove useless checks. 'num' is unsigned and cannot be <0.: ext/dba/libflatfile/flatfile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-84203@lists.php.net to get a copy of this message | ||
Commit: df67c4e8bd0c7c0f1fc976fad7f6fe5cbc01ef9b
Author: Joshua Rogers <git@internot.info> Fri, 16 Jan 2015 23:10:54 +1100
Committer: Julien Pauli <jpauli@php.net> Tue, 20 Jan 2015 14:54:48 +0100
Parents: b0159431e3363f6b15561c7dfa0cdb247c287223
Branches: PHP-5.5
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=df67c4e8bd0c7c0f1fc976fad7f6fe5cbc01ef9b
Log:
Fix bug #68711 Remove useless checks. 'num' is unsigned and cannot be <0.
Bugs:
https://bugs.php.net/68711
Changed paths:
M ext/dba/libflatfile/flatfile.c
Diff:
diff --git a/ext/dba/libflatfile/flatfile.c b/ext/dba/libflatfile/flatfile.c
index 8fd4205..e194608 100644
--- a/ext/dba/libflatfile/flatfile.c
+++ b/ext/dba/libflatfile/flatfile.c
@@ -126,9 +126,6 @@ int flatfile_delete(flatfile *dba, datum key_datum TSRMLS_DC) {
/* read in the key name */
num = php_stream_read(dba->fp, buf, num);
- if (num < 0) {
- break;
- }
if (size == num && !memcmp(buf, key, size)) {
php_stream_seek(dba->fp, pos, SEEK_SET);
@@ -150,9 +147,6 @@ int flatfile_delete(flatfile *dba, datum key_datum TSRMLS_DC) {
}
/* read in the value */
num = php_stream_read(dba->fp, buf, num);
- if (num < 0) {
- break;
- }
}
efree(buf);
return FAILURE;
@@ -180,9 +174,7 @@ int flatfile_findkey(flatfile *dba, datum key_datum TSRMLS_DC) {
buf = erealloc(buf, buf_size);
}
num = php_stream_read(dba->fp, buf, num);
- if (num < 0) {
- break;
- }
+
if (size == num) {
if (!memcmp(buf, key, size)) {
ret = 1;
@@ -198,9 +190,6 @@ int flatfile_findkey(flatfile *dba, datum key_datum TSRMLS_DC) {
buf = erealloc(buf, buf_size);
}
num = php_stream_read(dba->fp, buf, num);
- if (num < 0) {
- break;
- }
}
efree(buf);
return ret;
@@ -226,9 +215,7 @@ datum flatfile_firstkey(flatfile *dba TSRMLS_DC) {
buf = erealloc(buf, buf_size);
}
num = php_stream_read(dba->fp, buf, num);
- if (num < 0) {
- break;
- }
+
if (*(buf) != 0) {
dba->CurrentFlatFilePos = php_stream_tell(dba->fp);
res.dptr = buf;
@@ -244,9 +231,6 @@ datum flatfile_firstkey(flatfile *dba TSRMLS_DC) {
buf = erealloc(buf, buf_size);
}
num = php_stream_read(dba->fp, buf, num);
- if (num < 0) {
- break;
- }
}
efree(buf);
res.dptr = NULL;
@@ -274,9 +258,7 @@ datum flatfile_nextkey(flatfile *dba TSRMLS_DC) {
buf = erealloc(buf, buf_size);
}
num = php_stream_read(dba->fp, buf, num);
- if (num < 0) {
- break;
- }
+
if (!php_stream_gets(dba->fp, buf, 15)) {
break;
}
@@ -286,9 +268,7 @@ datum flatfile_nextkey(flatfile *dba TSRMLS_DC) {
buf = erealloc(buf, buf_size);
}
num = php_stream_read(dba->fp, buf, num);
- if (num < 0) {
- break;
- }
+
if (*(buf)!=0) {
dba->CurrentFlatFilePos = php_stream_tell(dba->fp);
res.dptr = buf;