Skip to content

Commit ac7ed28

Browse files
committed
ext/standard/info.c: Minor refactoring to php_get_windows_name()
1 parent 8448db8 commit ac7ed28

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

ext/standard/info.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static char* php_get_windows_name()
255255
OSVERSIONINFOEX osvi = EG(windows_version_info);
256256
SYSTEM_INFO si;
257257
DWORD dwType;
258-
char *major = NULL, *sub = NULL, *retval;
258+
const char *major = NULL, *sub = NULL;
259259

260260
ZeroMemory(&si, sizeof(SYSTEM_INFO));
261261

@@ -296,19 +296,19 @@ static char* php_get_windows_name()
296296
}
297297
} else if (VER_PLATFORM_WIN32_NT==osvi.dwPlatformId && osvi.dwMajorVersion >= 6) {
298298
if (osvi.dwMajorVersion == 6) {
299-
if( osvi.dwMinorVersion == 0 ) {
300-
if( osvi.wProductType == VER_NT_WORKSTATION ) {
299+
if (osvi.dwMinorVersion == 0) {
300+
if (osvi.wProductType == VER_NT_WORKSTATION) {
301301
major = "Windows Vista";
302302
} else {
303303
major = "Windows Server 2008";
304304
}
305-
} else if ( osvi.dwMinorVersion == 1 ) {
306-
if( osvi.wProductType == VER_NT_WORKSTATION ) {
305+
} else if (osvi.dwMinorVersion == 1) {
306+
if (osvi.wProductType == VER_NT_WORKSTATION) {
307307
major = "Windows 7";
308308
} else {
309309
major = "Windows Server 2008 R2";
310310
}
311-
} else if ( osvi.dwMinorVersion == 2 ) {
311+
} else if (osvi.dwMinorVersion == 2) {
312312
/* could be Windows 8/Windows Server 2012, could be Windows 8.1/Windows Server 2012 R2 */
313313
/* XXX and one more X - the above comment is true if no manifest is used for two cases:
314314
- if the PHP build doesn't use the correct manifest
@@ -333,20 +333,20 @@ static char* php_get_windows_name()
333333
VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR,
334334
dwlConditionMask)) {
335335
osvi.dwMinorVersion = 3; /* Windows 8.1/Windows Server 2012 R2 */
336-
if( osvi.wProductType == VER_NT_WORKSTATION ) {
336+
if (osvi.wProductType == VER_NT_WORKSTATION) {
337337
major = "Windows 8.1";
338338
} else {
339339
major = "Windows Server 2012 R2";
340340
}
341341
} else {
342-
if( osvi.wProductType == VER_NT_WORKSTATION ) {
342+
if (osvi.wProductType == VER_NT_WORKSTATION) {
343343
major = "Windows 8";
344344
} else {
345345
major = "Windows Server 2012";
346346
}
347347
}
348348
} else if (osvi.dwMinorVersion == 3) {
349-
if( osvi.wProductType == VER_NT_WORKSTATION ) {
349+
if (osvi.wProductType == VER_NT_WORKSTATION) {
350350
major = "Windows 8.1";
351351
} else {
352352
major = "Windows Server 2012 R2";
@@ -602,9 +602,10 @@ static char* php_get_windows_name()
602602
}
603603
}
604604
} else {
605-
return NULL;
605+
ZEND_UNREACHABLE();
606606
}
607607

608+
char *retval;
608609
spprintf(&retval, 0, "%s%s%s%s%s", major, sub?" ":"", sub?sub:"", osvi.szCSDVersion[0] != '\0'?" ":"", osvi.szCSDVersion);
609610
return retval;
610611
}

0 commit comments

Comments
 (0)