Skip to content

Commit 668a6d3

Browse files
committed
Reduce var scope
1 parent 050d624 commit 668a6d3

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

win32/codepage.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,10 @@ PW32CP wchar_t *php_win32_cp_env_any_to_w(const char* env)
407407

408408
do {
409409
wchar_t *tmp;
410-
size_t tmp_len;
411410

412411
tmp = php_win32_cp_any_to_w(cur);
413412
if (tmp) {
414-
tmp_len = wcslen(tmp) + 1;
413+
size_t tmp_len = wcslen(tmp) + 1;
415414
memmove(ew + bin_len, tmp, tmp_len * sizeof(wchar_t));
416415
free(tmp);
417416

win32/glob.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
622622
register struct dirent *dp;
623623
DIR *dirp;
624624
int err;
625-
char buf[MAXPATHLEN];
626625

627626
/*
628627
* The readdirfunc declaration can't be prototyped, because it is
@@ -640,6 +639,7 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
640639
if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
641640
/* TODO: don't call for ENOENT or ENOTDIR? */
642641
if (pglob->gl_errfunc) {
642+
char buf[MAXPATHLEN];
643643
if (g_Ctoc(pathbuf, buf, sizeof(buf)))
644644
return(GLOB_ABORTED);
645645
if (pglob->gl_errfunc(buf, errno) ||
@@ -712,7 +712,6 @@ globextend(path, pglob, limitp)
712712
size_t *limitp;
713713
{
714714
register char **pathv;
715-
register int i;
716715
u_int newsize, len;
717716
char *copy;
718717
const Char *p;
@@ -729,6 +728,7 @@ globextend(path, pglob, limitp)
729728
}
730729

731730
if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
731+
register int i;
732732
/* first time around -- clear initial gl_offs items */
733733
pathv += pglob->gl_offs;
734734
for (i = pglob->gl_offs; --i >= 0; )

win32/ioutil.c

+5-9
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ PW32IO int php_win32_ioutil_mkdir_w(const wchar_t *path, mode_t mode)
340340

341341
PW32IO int php_win32_ioutil_unlink_w(const wchar_t *path)
342342
{/*{{{*/
343-
int ret = 0;
344343
DWORD err = 0;
345344
HANDLE h;
346345
BY_HANDLE_FILE_INFORMATION info;
@@ -413,12 +412,11 @@ PW32IO int php_win32_ioutil_unlink_w(const wchar_t *path)
413412
PW32IO int php_win32_ioutil_rmdir_w(const wchar_t *path)
414413
{/*{{{*/
415414
int ret = 0;
416-
DWORD err = 0;
417415

418416
PHP_WIN32_IOUTIL_CHECK_PATH_W(path, -1, 0)
419417

420418
if (!RemoveDirectoryW(path)) {
421-
err = GetLastError();
419+
DWORD err = GetLastError();
422420
ret = -1;
423421
SET_ERRNO_FROM_WIN32_CODE(err);
424422
}
@@ -429,10 +427,9 @@ PW32IO int php_win32_ioutil_rmdir_w(const wchar_t *path)
429427
PW32IO int php_win32_ioutil_chdir_w(const wchar_t *path)
430428
{/*{{{*/
431429
int ret = 0;
432-
DWORD err = 0;
433430

434431
if (!SetCurrentDirectoryW(path)) {
435-
err = GetLastError();
432+
DWORD err = GetLastError();
436433
ret = -1;
437434
SET_ERRNO_FROM_WIN32_CODE(err);
438435
}
@@ -443,14 +440,13 @@ PW32IO int php_win32_ioutil_chdir_w(const wchar_t *path)
443440
PW32IO int php_win32_ioutil_rename_w(const wchar_t *oldname, const wchar_t *newname)
444441
{/*{{{*/
445442
int ret = 0;
446-
DWORD err = 0;
447443

448444
PHP_WIN32_IOUTIL_CHECK_PATH_W(oldname, -1, 0)
449445
PHP_WIN32_IOUTIL_CHECK_PATH_W(newname, -1, 0)
450446

451447

452448
if (!MoveFileExW(oldname, newname, MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED)) {
453-
err = GetLastError();
449+
DWORD err = GetLastError();
454450
ret = -1;
455451
SET_ERRNO_FROM_WIN32_CODE(err);
456452
}
@@ -640,7 +636,7 @@ BOOL php_win32_ioutil_init(void)
640636

641637
PW32IO int php_win32_ioutil_access_w(const wchar_t *path, mode_t mode)
642638
{/*{{{*/
643-
DWORD attr, err;
639+
DWORD attr;
644640

645641
if ((mode & X_OK) == X_OK) {
646642
DWORD type;
@@ -649,7 +645,7 @@ PW32IO int php_win32_ioutil_access_w(const wchar_t *path, mode_t mode)
649645

650646
attr = GetFileAttributesW(path);
651647
if (attr == INVALID_FILE_ATTRIBUTES) {
652-
err = GetLastError();
648+
DWORD err = GetLastError();
653649
SET_ERRNO_FROM_WIN32_CODE(err);
654650
return -1;
655651
}

0 commit comments

Comments
 (0)