Skip to content

Commit 89e0c2f

Browse files
committed
fix warnings regarding stream_ops order
1 parent 684a979 commit 89e0c2f

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

main/php_streams.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ typedef struct _php_stream_ops {
117117
ssize_t (*read)(php_stream *stream, char *buf, size_t count);
118118
int (*close)(php_stream *stream, int close_handle);
119119
int (*flush)(php_stream *stream);
120-
int (*sync)(php_stream *stream);
121120

122121
const char *label; /* label for this ops structure */
123122

@@ -126,6 +125,7 @@ typedef struct _php_stream_ops {
126125
int (*cast)(php_stream *stream, int castas, void **ret);
127126
int (*stat)(php_stream *stream, php_stream_statbuf *ssb);
128127
int (*set_option)(php_stream *stream, int option, int value, void *ptrparam);
128+
int (*sync)(php_stream *stream);
129129
} php_stream_ops;
130130

131131
typedef struct _php_stream_wrapper_ops {

main/streams/glob_wrapper.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ const php_stream_ops php_glob_stream_ops = {
190190
php_glob_stream_rewind,
191191
NULL, /* cast */
192192
NULL, /* stat */
193-
NULL /* set_option */
193+
NULL, /* set_option */
194+
NULL
194195
};
195196

196197
/* {{{ php_glob_stream_opener */

main/streams/plain_wrapper.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,17 @@ static int php_stdiop_close(php_stream *stream, int close_handle)
524524
static int php_stdiop_sync(php_stream *stream)
525525
{
526526
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
527+
int ret = 0;
527528

528529
assert(data != NULL);
529530

530531
if (data->file) {
531-
fflush(data->file);
532-
return fsync(fileno(data->file));
532+
ret = fflush(data->file);
533+
if (ret != 0) {
534+
return fsync(fileno(data->file));
535+
}
533536
}
534-
return 0;
535-
537+
return ret;
536538
}
537539

538540
static int php_stdiop_flush(php_stream *stream)
@@ -973,12 +975,12 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
973975
PHPAPI php_stream_ops php_stream_stdio_ops = {
974976
php_stdiop_write, php_stdiop_read,
975977
php_stdiop_close, php_stdiop_flush,
976-
php_stdiop_sync,
977978
"STDIO",
978979
php_stdiop_seek,
979980
php_stdiop_cast,
980981
php_stdiop_stat,
981-
php_stdiop_set_option
982+
php_stdiop_set_option,
983+
php_stdiop_sync,
982984
};
983985
/* }}} */
984986

0 commit comments

Comments
 (0)