]> granicus.if.org Git - php/commitdiff
Reduce var scope
authorAnatol Belski <ab@php.net>
Mon, 19 Feb 2018 15:09:37 +0000 (16:09 +0100)
committerAnatol Belski <ab@php.net>
Mon, 19 Feb 2018 16:43:48 +0000 (17:43 +0100)
win32/codepage.c
win32/glob.c
win32/ioutil.c

index 74e33230976c80beda47c1e4202567808d09ff82..16e480e5fff5ca1eb36cf416c4c439cc2a2ad71c 100644 (file)
@@ -407,11 +407,10 @@ PW32CP wchar_t *php_win32_cp_env_any_to_w(const char* env)
 
        do {
                wchar_t *tmp;
-               size_t tmp_len;
 
                tmp = php_win32_cp_any_to_w(cur);
                if (tmp) {
-                       tmp_len = wcslen(tmp) + 1;
+                       size_t tmp_len = wcslen(tmp) + 1;
                        memmove(ew + bin_len, tmp, tmp_len * sizeof(wchar_t));
                        free(tmp);
 
index 8c74ae7c3c10093cde6cec857ba4a7deb31a3e2c..21a7cc70ef5a35ae6d2f2cab43f06fd4b76de78c 100644 (file)
@@ -622,7 +622,6 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
        register struct dirent *dp;
        DIR *dirp;
        int err;
-       char buf[MAXPATHLEN];
 
        /*
         * The readdirfunc declaration can't be prototyped, because it is
@@ -640,6 +639,7 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
        if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
                /* TODO: don't call for ENOENT or ENOTDIR? */
                if (pglob->gl_errfunc) {
+                       char buf[MAXPATHLEN];
                        if (g_Ctoc(pathbuf, buf, sizeof(buf)))
                                return(GLOB_ABORTED);
                        if (pglob->gl_errfunc(buf, errno) ||
@@ -712,7 +712,6 @@ globextend(path, pglob, limitp)
        size_t *limitp;
 {
        register char **pathv;
-       register int i;
        u_int newsize, len;
        char *copy;
        const Char *p;
@@ -729,6 +728,7 @@ globextend(path, pglob, limitp)
        }
 
        if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
+               register int i;
                /* first time around -- clear initial gl_offs items */
                pathv += pglob->gl_offs;
                for (i = pglob->gl_offs; --i >= 0; )
index d73afe7bbd42686f1055402622c934d00e810a35..932b4a2fbc9c01debad38631369a48ae31f24e0d 100644 (file)
@@ -340,7 +340,6 @@ PW32IO int php_win32_ioutil_mkdir_w(const wchar_t *path, mode_t mode)
 
 PW32IO int php_win32_ioutil_unlink_w(const wchar_t *path)
 {/*{{{*/
-       int ret = 0;
        DWORD err = 0;
        HANDLE h;
        BY_HANDLE_FILE_INFORMATION info;
@@ -413,12 +412,11 @@ PW32IO int php_win32_ioutil_unlink_w(const wchar_t *path)
 PW32IO int php_win32_ioutil_rmdir_w(const wchar_t *path)
 {/*{{{*/
        int ret = 0;
-       DWORD err = 0;
 
        PHP_WIN32_IOUTIL_CHECK_PATH_W(path, -1, 0)
 
        if (!RemoveDirectoryW(path)) {
-               err = GetLastError();
+               DWORD err = GetLastError();
                ret = -1;
                SET_ERRNO_FROM_WIN32_CODE(err);
        }
@@ -429,10 +427,9 @@ PW32IO int php_win32_ioutil_rmdir_w(const wchar_t *path)
 PW32IO int php_win32_ioutil_chdir_w(const wchar_t *path)
 {/*{{{*/
        int ret = 0;
-       DWORD err = 0;
 
        if (!SetCurrentDirectoryW(path)) {
-               err = GetLastError();
+               DWORD err = GetLastError();
                ret = -1;
                SET_ERRNO_FROM_WIN32_CODE(err);
        }
@@ -443,14 +440,13 @@ PW32IO int php_win32_ioutil_chdir_w(const wchar_t *path)
 PW32IO int php_win32_ioutil_rename_w(const wchar_t *oldname, const wchar_t *newname)
 {/*{{{*/
        int ret = 0;
-       DWORD err = 0;
 
        PHP_WIN32_IOUTIL_CHECK_PATH_W(oldname, -1, 0)
        PHP_WIN32_IOUTIL_CHECK_PATH_W(newname, -1, 0)
 
 
        if (!MoveFileExW(oldname, newname, MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED)) {
-               err = GetLastError();
+               DWORD err = GetLastError();
                ret = -1;
                SET_ERRNO_FROM_WIN32_CODE(err);
        }
@@ -640,7 +636,7 @@ BOOL php_win32_ioutil_init(void)
 
 PW32IO int php_win32_ioutil_access_w(const wchar_t *path, mode_t mode)
 {/*{{{*/
-       DWORD attr, err;
+       DWORD attr;
 
        if ((mode & X_OK) == X_OK) {
                DWORD type;
@@ -649,7 +645,7 @@ PW32IO int php_win32_ioutil_access_w(const wchar_t *path, mode_t mode)
 
        attr = GetFileAttributesW(path);
        if (attr == INVALID_FILE_ATTRIBUTES) {
-               err = GetLastError();
+               DWORD err = GetLastError();
                SET_ERRNO_FROM_WIN32_CODE(err);
                return -1;
        }