Skip to content

Commit 749445a

Browse files
cmb69nikic
andcommitted
Refactor code for better readability
Co-authored-by: Nikita Popov <[email protected]>
1 parent 58e72db commit 749445a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

main/streams/plain_wrapper.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,11 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
838838

839839
GetSystemInfo(&info);
840840
gran = info.dwAllocationGranularity;
841-
loffs = ((DWORD)range->offset / gran) * gran;
842-
delta = (DWORD)range->offset - loffs;
843-
hoffs = range->offset >> 32;
841+
ZEND_ASSERT(gran != 0 && (gran & (gran - 1)) == 0);
842+
size_t rounded_offset = (range->offset / gran) * gran;
843+
delta = range->offset - rounded_offset;
844+
loffs = (DWORD)rounded_offset;
845+
hoffs = (DWORD)(rounded_offset >> 32);
844846
}
845847

846848
/* MapViewOfFile()ing zero bytes would map to the end of the file; match *nix behavior instead */

0 commit comments

Comments
 (0)