]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
A bunch of further warning fixes in the Windows code.
authorSimon Tatham <anakin@pobox.com>
Fri, 3 Feb 2017 19:37:59 +0000 (19:37 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 3 Feb 2017 19:37:59 +0000 (19:37 +0000)
These ones are stylistic rather than potential bugs: mostly signedness
of char pointers in cases where they clearly aren't going to cause the
wrong thing to actually happen, and one thing in winsecur.c where
clang would have preferred an extra pair of braces around some
initialisers but it's legal with or without. But since some of clang's
warnings turn out to be quite useful, it seems worth silencing these
harmless ones so as to be able to see the rest.

windows/window.c
windows/wingss.c
windows/winprint.c
windows/winsecur.c
windows/winstore.c

index 5ef3a46077157fd33d603f0e9466c2e0df48d041..4ce9b7b2f028d407f81cc562abd5b5274830fb59 100644 (file)
@@ -3131,7 +3131,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                     */
                    term_seen_key_event(term);
                    if (ldisc)
-                       ldisc_send(ldisc, buf, len, 1);
+                       ldisc_send(ldisc, (char *)buf, len, 1);
                    show_mouseptr(0);
                }
            }
@@ -3199,7 +3199,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
 
       case WM_IME_CHAR:
        if (wParam & 0xFF00) {
-           unsigned char buf[2];
+           char buf[2];
 
            buf[1] = wParam;
            buf[0] = wParam >> 8;
@@ -4604,7 +4604,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
                break;
            }
            if (xkey) {
-               p += format_arrow_key(p, term, xkey, shift_state);
+               p += format_arrow_key((char *)p, term, xkey, shift_state);
                return p - output;
            }
        }
index 0187a5a7c19bde2359cf3ea622550bc8aa1ae276..6aaa20cf2c45ccb6956864a2131a3a3fc056fc72 100644 (file)
@@ -91,7 +91,7 @@ struct ssh_gss_liblist *ssh_gss_setup(Conf *conf)
        if (ret == ERROR_SUCCESS && type == REG_SZ) {
            buffer = snewn(size + 20, char);
            ret = RegQueryValueEx(regkey, "InstallDir", NULL,
-                                 &type, buffer, &size);
+                                 &type, (LPBYTE)buffer, &size);
            if (ret == ERROR_SUCCESS && type == REG_SZ) {
                strcat(buffer, "\\bin\\gssapi32.dll");
                module = LoadLibrary(buffer);
index bc5a5d12bf8028138c272274e9183b5907c1ee56..c190e5fb0d0cf4c89d59573f2ba6e0556b0feb03 100644 (file)
@@ -30,7 +30,7 @@ static int printer_add_enum(int param, DWORD level, char **buffer,
      * we'll need for the output. Discard the return value since it
      * will almost certainly be a failure due to lack of space.
      */
-    EnumPrinters(param, NULL, level, (*buffer)+offset, 512,
+    EnumPrinters(param, NULL, level, (LPBYTE)((*buffer)+offset), 512,
                 &needed, &nprinters);
 
     if (needed < 512)
@@ -38,7 +38,7 @@ static int printer_add_enum(int param, DWORD level, char **buffer,
 
     *buffer = sresize(*buffer, offset+needed, char);
 
-    if (EnumPrinters(param, NULL, level, (*buffer)+offset,
+    if (EnumPrinters(param, NULL, level, (LPBYTE)((*buffer)+offset),
                      needed, &needed, &nprinters) == 0)
         return FALSE;
 
@@ -139,7 +139,7 @@ printer_job *printer_start_job(char *printer)
     docinfo.pOutputFile = NULL;
     docinfo.pDatatype = "RAW";
 
-    if (!StartDocPrinter(ret->hprinter, 1, (LPSTR)&docinfo))
+    if (!StartDocPrinter(ret->hprinter, 1, (LPBYTE)&docinfo))
        goto error;
     jobstarted = 1;
 
index b7060b3b0a5d2a681360aaff1cb0b5b2c2341031..cba7d60a196993a742851deb9a49373644c93b91 100644 (file)
@@ -94,8 +94,8 @@ PSID get_user_sid(void)
 
 int getsids(char **error)
 {
-    SID_IDENTIFIER_AUTHORITY world_auth = SECURITY_WORLD_SID_AUTHORITY;
-    SID_IDENTIFIER_AUTHORITY nt_auth = SECURITY_NT_AUTHORITY;
+    SID_IDENTIFIER_AUTHORITY world_auth = { SECURITY_WORLD_SID_AUTHORITY };
+    SID_IDENTIFIER_AUTHORITY nt_auth = { SECURITY_NT_AUTHORITY };
     int ret = FALSE;
 
     *error = NULL;
index 6944849658f5ff185df52bfee39e239a6dce31e0..26cbf63496e9fdbb2c04d439c810144c2738738a 100644 (file)
@@ -110,7 +110,7 @@ void *open_settings_w(const char *sessionname, char **errmsg)
 void write_setting_s(void *handle, const char *key, const char *value)
 {
     if (handle)
-       RegSetValueEx((HKEY) handle, key, 0, REG_SZ, value,
+       RegSetValueEx((HKEY) handle, key, 0, REG_SZ, (CONST BYTE *)value,
                      1 + strlen(value));
 }
 
@@ -168,7 +168,7 @@ char *read_setting_s(void *handle, const char *key)
     allocsize = size+1;         /* allow for an extra NUL if needed */
     ret = snewn(allocsize, char);
     if (RegQueryValueEx((HKEY) handle, key, 0,
-                       &type, ret, &size) != ERROR_SUCCESS ||
+                       &type, (BYTE *)ret, &size) != ERROR_SUCCESS ||
        type != REG_SZ) {
         sfree(ret);
         return NULL;
@@ -372,7 +372,8 @@ int verify_host_key(const char *hostname, int port,
 
     readlen = len;
     otherstr = snewn(len, char);
-    ret = RegQueryValueEx(rkey, regname, NULL, &type, otherstr, &readlen);
+    ret = RegQueryValueEx(rkey, regname, NULL,
+                          &type, (BYTE *)otherstr, &readlen);
 
     if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA &&
        !strcmp(keytype, "rsa")) {
@@ -385,7 +386,7 @@ int verify_host_key(const char *hostname, int port,
        char *oldstyle = snewn(len + 10, char); /* safety margin */
        readlen = len;
        ret = RegQueryValueEx(rkey, justhost, NULL, &type,
-                             oldstyle, &readlen);
+                             (BYTE *)oldstyle, &readlen);
 
        if (ret == ERROR_SUCCESS && type == REG_SZ) {
            /*
@@ -431,7 +432,7 @@ int verify_host_key(const char *hostname, int port,
             * wrong, and hyper-cautiously do nothing.
             */
            if (!strcmp(otherstr, key))
-               RegSetValueEx(rkey, regname, 0, REG_SZ, otherstr,
+               RegSetValueEx(rkey, regname, 0, REG_SZ, (BYTE *)otherstr,
                              strlen(otherstr) + 1);
        }
 
@@ -476,7 +477,7 @@ void store_host_key(const char *hostname, int port,
 
     if (RegCreateKey(HKEY_CURRENT_USER, PUTTY_REG_POS "\\SshHostKeys",
                     &rkey) == ERROR_SUCCESS) {
-       RegSetValueEx(rkey, regname, 0, REG_SZ, key, strlen(key) + 1);
+       RegSetValueEx(rkey, regname, 0, REG_SZ, (BYTE *)key, strlen(key) + 1);
        RegCloseKey(rkey);
     } /* else key does not exist in registry */
 
@@ -536,7 +537,7 @@ static HANDLE access_random_seed(int action)
     if (RegOpenKey(HKEY_CURRENT_USER, PUTTY_REG_POS, &rkey) ==
        ERROR_SUCCESS) {
        int ret = RegQueryValueEx(rkey, "RandSeedFile",
-                                 0, &type, seedpath, &size);
+                                 0, &type, (BYTE *)seedpath, &size);
        if (ret != ERROR_SUCCESS || type != REG_SZ)
            seedpath[0] = '\0';
        RegCloseKey(rkey);
@@ -672,7 +673,7 @@ static int transform_jumplist_registry
     value_length = 200;
     old_value = snewn(value_length, char);
     ret = RegQueryValueEx(pjumplist_key, reg_jumplist_value, NULL, &type,
-                          old_value, &value_length);
+                          (BYTE *)old_value, &value_length);
     /* When the passed buffer is too small, ERROR_MORE_DATA is
      * returned and the required size is returned in the length
      * argument. */
@@ -680,7 +681,7 @@ static int transform_jumplist_registry
         sfree(old_value);
         old_value = snewn(value_length, char);
         ret = RegQueryValueEx(pjumplist_key, reg_jumplist_value, NULL, &type,
-                              old_value, &value_length);
+                              (BYTE *)old_value, &value_length);
     }
 
     if (ret == ERROR_FILE_NOT_FOUND) {
@@ -754,7 +755,7 @@ static int transform_jumplist_registry
 
         /* Save the new list to the registry. */
         ret = RegSetValueEx(pjumplist_key, reg_jumplist_value, 0, REG_MULTI_SZ,
-                            new_value, piterator_new - new_value);
+                            (BYTE *)new_value, piterator_new - new_value);
 
         sfree(old_value);
         old_value = new_value;