Skip to content

Commit b35dbe4

Browse files
committed
streams: reduce scope of variables
1 parent 17b8706 commit b35dbe4

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

ext/standard/streamsfuncs.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ PHP_FUNCTION(stream_socket_client)
9999
zval *zerrno = NULL, *zerrstr = NULL, *zcontext = NULL;
100100
double timeout;
101101
bool timeout_is_null = 1;
102-
php_timeout_ull conv;
103102
struct timeval tv;
104103
char *hashkey = NULL;
105104
php_stream *stream = NULL;
@@ -138,7 +137,7 @@ PHP_FUNCTION(stream_socket_client)
138137
if (timeout < 0.0 || timeout >= (double) PHP_TIMEOUT_ULL_MAX / 1000000.0) {
139138
tv_pointer = NULL;
140139
} else {
141-
conv = (php_timeout_ull) (timeout * 1000000.0);
140+
php_timeout_ull conv = (php_timeout_ull) (timeout * 1000000.0);
142141
#ifdef PHP_WIN32
143142
tv.tv_sec = (long)(conv / 1000000);
144143
tv.tv_usec = (long)(conv % 1000000);
@@ -262,7 +261,6 @@ PHP_FUNCTION(stream_socket_accept)
262261
bool timeout_is_null = 1;
263262
zval *zpeername = NULL;
264263
zend_string *peername = NULL;
265-
php_timeout_ull conv;
266264
struct timeval tv;
267265
php_stream *stream = NULL, *clistream = NULL;
268266
zend_string *errstr = NULL;
@@ -286,7 +284,7 @@ PHP_FUNCTION(stream_socket_accept)
286284
if (timeout < 0.0 || timeout >= (double) PHP_TIMEOUT_ULL_MAX / 1000000.0) {
287285
tv_pointer = NULL;
288286
} else {
289-
conv = (php_timeout_ull) (timeout * 1000000.0);
287+
php_timeout_ull conv = (php_timeout_ull) (timeout * 1000000.0);
290288
#ifdef PHP_WIN32
291289
tv.tv_sec = (long)(conv / 1000000);
292290
tv.tv_usec = (long)(conv % 1000000);

main/streams/streams.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ PHPAPI int _php_stream_stat(php_stream *stream, php_stream_statbuf *ssb)
880880
PHPAPI const char *php_stream_locate_eol(php_stream *stream, zend_string *buf)
881881
{
882882
size_t avail;
883-
const char *cr, *lf, *eol = NULL;
883+
const char *eol = NULL;
884884
const char *readptr;
885885

886886
if (!buf) {
@@ -893,8 +893,8 @@ PHPAPI const char *php_stream_locate_eol(php_stream *stream, zend_string *buf)
893893

894894
/* Look for EOL */
895895
if (stream->flags & PHP_STREAM_FLAG_DETECT_EOL) {
896-
cr = memchr(readptr, '\r', avail);
897-
lf = memchr(readptr, '\n', avail);
896+
const char *cr = memchr(readptr, '\r', avail);
897+
const char *lf = memchr(readptr, '\n', avail);
898898

899899
if (cr && lf != cr + 1 && !(lf && lf < cr)) {
900900
/* mac */
@@ -1218,16 +1218,15 @@ static ssize_t _php_stream_write_filtered(php_stream *stream, const char *buf, s
12181218
size_t consumed = 0;
12191219
php_stream_bucket *bucket;
12201220
php_stream_bucket_brigade brig_in = { NULL, NULL }, brig_out = { NULL, NULL };
1221-
php_stream_bucket_brigade *brig_inp = &brig_in, *brig_outp = &brig_out, *brig_swap;
1221+
php_stream_bucket_brigade *brig_inp = &brig_in, *brig_outp = &brig_out;
12221222
php_stream_filter_status_t status = PSFS_ERR_FATAL;
1223-
php_stream_filter *filter;
12241223

12251224
if (buf) {
12261225
bucket = php_stream_bucket_new(stream, (char *)buf, count, 0, 0);
12271226
php_stream_bucket_append(&brig_in, bucket);
12281227
}
12291228

1230-
for (filter = stream->writefilters.head; filter; filter = filter->next) {
1229+
for (php_stream_filter *filter = stream->writefilters.head; filter; filter = filter->next) {
12311230
/* for our return value, we are interested in the number of bytes consumed from
12321231
* the first filter in the chain */
12331232
status = filter->fops->filter(stream, filter, brig_inp, brig_outp,
@@ -1239,7 +1238,7 @@ static ssize_t _php_stream_write_filtered(php_stream *stream, const char *buf, s
12391238
/* brig_out becomes brig_in.
12401239
* brig_in will always be empty here, as the filter MUST attach any un-consumed buckets
12411240
* to its own brigade */
1242-
brig_swap = brig_inp;
1241+
php_stream_bucket_brigade *brig_swap = brig_inp;
12431242
brig_inp = brig_outp;
12441243
brig_outp = brig_swap;
12451244
memset(brig_outp, 0, sizeof(*brig_outp));

0 commit comments

Comments
 (0)