]> git.proxmox.com Git - mirror_edk2.git/commitdiff
* StdLib.dsc was changed to always build the sockets code.
authorlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 17 Feb 2012 23:43:35 +0000 (23:43 +0000)
committerlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 17 Feb 2012 23:43:35 +0000 (23:43 +0000)
* Fix errors detected by the GCC compiler (pointer conversions and format mismatches).
* Worked around a GCC flow analysis issue in base64.c where the compiler is convinced that there is a path through the code where "input" is used but not initialized.
* Added EFIAPI to the file system operation routines for sockets to match the API declaration.

Note for GCC, the meaning of "l" and "L" are different in printf and sscanf format strings.  The lower case "l" indicates a 32-bit value where the capital "L" indicates a 64-bit value.  The native (default) integer size may be represented by a size letter of "n".

Signed-off-by: lpleahy
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13023 6f19259b-4bc3-4df7-8a09-765794883524

13 files changed:
StdLib/BsdSocketLib/SocketInternals.h
StdLib/BsdSocketLib/base64.c
StdLib/BsdSocketLib/close.c
StdLib/BsdSocketLib/getaddrinfo.c
StdLib/BsdSocketLib/inet_net_ntop.c
StdLib/BsdSocketLib/ns_ntoa.c
StdLib/BsdSocketLib/ns_print.c
StdLib/BsdSocketLib/poll.c
StdLib/BsdSocketLib/read.c
StdLib/BsdSocketLib/res_debug.c
StdLib/BsdSocketLib/res_send.c
StdLib/BsdSocketLib/write.c
StdLib/StdLib.dsc

index 1b19869c0d4f727e986a2220a6629b5ee6ae038e..c30f7fb6612bed437ec9f7deb4c57ee5250b8ef4 100644 (file)
@@ -82,6 +82,7 @@ BslFdToSocketProtocol (
 \r
 **/\r
 int\r
+EFIAPI\r
 BslSocketClose (\r
   struct __filedes * pDescriptor\r
   );\r
@@ -113,6 +114,7 @@ BslSocketCloseWork (
 \r
  **/\r
 short\r
+EFIAPI\r
 BslSocketPoll (\r
   IN struct __filedes * pDescriptor,\r
   IN short Events\r
@@ -152,6 +154,7 @@ BslSocketProtocolToFd (
 \r
 **/\r
 ssize_t\r
+EFIAPI\r
 BslSocketRead (\r
   struct __filedes *pDescriptor,\r
   off_t * pOffset,\r
@@ -172,6 +175,7 @@ BslSocketRead (
 \r
 **/\r
 ssize_t\r
+EFIAPI\r
 BslSocketWrite (\r
   struct __filedes *pDescriptor,\r
   off_t * pOffset,\r
index d8c588d19dd2964b16aa128baa53b13dae065b9e..363ee18591cb5e1ab4d7741874ea838c4248d4c3 100644 (file)
@@ -171,6 +171,7 @@ b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize) {
   u_char output[4];\r
   size_t i;\r
 \r
+  input[0] = input[1] = input[2] = '\0';\r
   while (2 < srclength) {\r
     input[0] = *src++;\r
     input[1] = *src++;\r
index 3dfeb2bf1895b05e86124f1dd34e216433b2def1..f3f7e98cbace304c08678cfa70293799f5eb2df2 100644 (file)
@@ -94,6 +94,7 @@ BslSocketCloseWork (
 \r
 **/\r
 int\r
+EFIAPI\r
 BslSocketClose (\r
   struct __filedes * pDescriptor\r
   )\r
index c8ed7848a427a11b4b29974dcb93b6bc9dae6fdc..5a0baf6d45f55226afce539b86f29af3e03ab9af 100644 (file)
@@ -557,8 +557,8 @@ getaddrinfo(const char *hostname, const char *servname,
 }\r
 \r
 static const ns_dtab dtab[] = {\r
-  NS_FILES_CB(_files_getaddrinfo, NULL)\r
-  { NSSRC_DNS, _dns_getaddrinfo, NULL },  /* force -DHESIOD */\r
+  NS_FILES_CB(((nss_method)_files_getaddrinfo), NULL)\r
+  { NSSRC_DNS, ((nss_method)_dns_getaddrinfo), NULL },  /* force -DHESIOD */\r
   NS_NIS_CB(_yp_getaddrinfo, NULL)\r
   NS_NULL_CB\r
 };\r
index 3925727878f2f57463a2608a7bbe1a9ddde05615..e7411434f92ac4aed1109166895cebb7ddc121d7 100644 (file)
@@ -126,7 +126,7 @@ inet_net_ntop_ipv4(
                if (dst != odst)\r
                        *dst++ = '.';\r
                m = ((1 << b) - 1) << (8 - b);\r
-               dst += SPRINTF((dst, "%u", *src & m));\r
+               dst += SPRINTF((dst, "%u", ((unsigned int)(*src & m))));\r
                size -= (size_t)(dst - t);\r
        }\r
 \r
index 1162b4d69af1729fcc6e3291042723c10aecea91..d079dc86699427a7ad63b162e5790b3546072904 100644 (file)
@@ -55,7 +55,7 @@ ns_ntoa(
        u_char *uplim = up + 6;\r
 \r
        net.net_e = addr.x_net;\r
-       sprintf(obuf, "%lx", (u_long)ntohl(net.long_e));\r
+       sprintf(obuf, "%Lx", (u_long)ntohl(net.long_e));\r
        cp = spectHex(obuf);\r
        cp2 = cp + 1;\r
        while (*up==0 && up < uplim) up++;\r
index ff7047a1fd409b148eabe25561ed3fd72b64aad0..a5d8ad3d7d2ad432aa7440ca8137e733ba9c18d5 100644 (file)
@@ -228,7 +228,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
                /* Serial number. */\r
                t = ns_get32(rdata);  rdata += NS_INT32SZ;\r
                T(addstr("\t\t\t\t\t", 5, &buf, &buflen));\r
-               len = SPRINTF((tmp, "%lu", t));\r
+               len = SPRINTF((tmp, "%Lu", t));\r
                T(addstr(tmp, len, &buf, &buflen));\r
                T(spaced = addtab(len, 16, spaced, &buf, &buflen));\r
                T(addstr("; serial\n", 9, &buf, &buflen));\r
@@ -284,7 +284,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
                /* Priority. */\r
                t = ns_get16(rdata);\r
                rdata += NS_INT16SZ;\r
-               len = SPRINTF((tmp, "%u ", t));\r
+               len = SPRINTF((tmp, "%u ", (unsigned int)t));\r
                T(addstr(tmp, len, &buf, &buflen));\r
 \r
                /* Target. */\r
@@ -302,7 +302,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
                /* Priority. */\r
                t = ns_get16(rdata);\r
                rdata += NS_INT16SZ;\r
-               len = SPRINTF((tmp, "%u ", t));\r
+               len = SPRINTF((tmp, "%u ", (unsigned int)t));\r
                T(addstr(tmp, len, &buf, &buflen));\r
 \r
                /* Name1. */\r
@@ -363,7 +363,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
                /* Order, Precedence. */\r
                order = ns_get16(rdata);        rdata += NS_INT16SZ;\r
                preference = ns_get16(rdata);   rdata += NS_INT16SZ;\r
-               len = SPRINTF((t, "%u %u ", order, preference));\r
+               len = SPRINTF((t, "%u %u ", (unsigned int)order, (unsigned int)preference));\r
                T(addstr(t, len, &buf, &buflen));\r
 \r
                /* Flags. */\r
@@ -404,7 +404,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
                priority = ns_get16(rdata);  rdata += NS_INT16SZ;\r
                weight   = ns_get16(rdata);  rdata += NS_INT16SZ;\r
                port     = ns_get16(rdata);  rdata += NS_INT16SZ;\r
-               len = SPRINTF((t, "%u %u %u ", priority, weight, port));\r
+               len = SPRINTF((t, "%u %u %u ", (unsigned int)priority, (unsigned int)weight, (unsigned int)port));\r
                T(addstr(t, len, &buf, &buflen));\r
 \r
                /* Server. */\r
@@ -477,7 +477,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
                protocol = *rdata++;\r
                algorithm = *rdata++;\r
                len = SPRINTF((tmp, "0x%04x %u %u",\r
-                              keyflags, protocol, algorithm));\r
+                              (unsigned int)keyflags, (unsigned int)protocol, (unsigned int)algorithm));\r
                T(addstr(tmp, len, &buf, &buflen));\r
 \r
                /* Public key data. */\r
@@ -516,8 +516,8 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
                algorithm = *rdata++;\r
                labels = *rdata++;\r
                t = ns_get32(rdata);  rdata += NS_INT32SZ;\r
-               len = SPRINTF((tmp, " %s %d %lu ",\r
-                              p_type((int)type), algorithm, t));\r
+               len = SPRINTF((tmp, " %s %d %Lu ",\r
+                              p_type((int)type), (int)algorithm, t));\r
                T(addstr(tmp, len, &buf, &buflen));\r
                if (labels != (u_int)dn_count_labels(name))\r
                        goto formerr;\r
@@ -534,7 +534,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
 \r
                /* Signature Footprint. */\r
                footprint = ns_get16(rdata);  rdata += NS_INT16SZ;\r
-               len = SPRINTF((tmp, "%u ", footprint));\r
+               len = SPRINTF((tmp, "%u ", (unsigned int)footprint));\r
                T(addstr(tmp, len, &buf, &buflen));\r
 \r
                /* Signer's name. */\r
index 336924d556ab92a3d34c64413fcfcf6923a01182..dc175676620cb002dd9a9abdfa815451fc1cde7c 100644 (file)
@@ -26,6 +26,7 @@
 \r
  **/\r
 short\r
+EFIAPI\r
 BslSocketPoll (\r
   IN struct __filedes * pDescriptor,\r
   IN short Events\r
index 293c1014636ad93387471cf628b1fec89bb0e514..f4348a51dc34562fe971fc9b78be82358142d623 100644 (file)
@@ -33,6 +33,7 @@
 \r
 **/\r
 ssize_t\r
+EFIAPI\r
 BslSocketRead (\r
   struct __filedes *pDescriptor,\r
   off_t * pOffset,\r
index 5cdc67457255f7ef93c4686fdf5ddfd21156dff3..5dc0302eecd9a60f629270d35c215cfffa08da3b 100644 (file)
@@ -243,7 +243,7 @@ fp_nquery(const u_char *msg, int len, FILE *file) {
     if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX) || rcode)\r
         fprintf(file,\r
             ";; ->>HEADER<<- opcode: %s, status: %s, id: %d\n",\r
-            _res_opcodes[opcode], _res_resultcodes[rcode], id);\r
+            _res_opcodes[opcode], _res_resultcodes[rcode], (int)id);\r
     if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX))\r
         putc(';', file);\r
     if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD2)) {\r
@@ -536,7 +536,7 @@ p_option(u_long option) {
     case RES_DNSRCH:    return "dnsrch";\r
     case RES_INSECURE1: return "insecure1";\r
     case RES_INSECURE2: return "insecure2";\r
-    default:        sprintf(nbuf, "?0x%lx?", (u_long)option);\r
+    default:        sprintf(nbuf, "?0x%Lx?", (u_long)option);\r
                 return (nbuf);\r
     }\r
 }\r
index 0b887e79d091f3108d655267413b8035512645bc..d9ae46558e2fea2f2600ea26dfd1b276b423ccd8 100644 (file)
@@ -114,7 +114,6 @@ static char rcsid[] = "$Id: res_send.c,v 1.1.1.1 2003/11/19 01:51:39 kyu3 Exp $"
 #endif\r
 \r
 #ifdef NOPOLL           /* libc_r doesn't wrap poll yet() */\r
-static int use_poll = 0;\r
 #else\r
 #include <poll.h>\r
 static int use_poll = 1;    /* adapt to poll() syscall availability */\r
@@ -855,10 +854,10 @@ read_len:
                ((_res.pfcode & RES_PRF_REPLY) &&\r
             (_res.pfcode & RES_PRF_HEAD1)),\r
                (stdout, ";; got answer:\n"));\r
-        DprintQ((_res.options & RES_DEBUG) ||\r
-            (_res.pfcode & RES_PRF_REPLY),\r
-            (stdout, ""),\r
-            ans, (resplen>anssiz)?anssiz:resplen);\r
+        if((_res.options & RES_DEBUG) ||\r
+            (_res.pfcode & RES_PRF_REPLY)) {\r
+            __fp_nquery(ans, (resplen>anssiz)?anssiz:resplen, stdout);\r
+        }\r
         /*\r
          * If using virtual circuits, we assume that the first server\r
          * is preferred over the rest (i.e. it is on the local\r
index 1f8ad004b572736b19180a802672e5dd49a42957..a6856b5616680c1c82cede33f018244d5eaabbec 100644 (file)
@@ -28,6 +28,7 @@
 \r
 **/\r
 ssize_t\r
+EFIAPI\r
 BslSocketWrite (\r
   struct __filedes *pDescriptor,\r
   off_t * pOffset,\r
index d01a2d6cb904c65f44c7676305c9a25e6e03b0a0..c352b22455695adef3e71a424965600fab9896a2 100644 (file)
   StdLib/PosixLib/Stringlist/LibStringlist.inf\r
 \r
 #    Socket Libraries - LibC based\r
-#  StdLib/BsdSocketLib/BsdSocketLib.inf\r
-#  StdLib/EfiSocketLib/EfiSocketLib.inf\r
-#  StdLib/UseSocketDxe/UseSocketDxe.inf\r
+  StdLib/BsdSocketLib/BsdSocketLib.inf\r
+  StdLib/EfiSocketLib/EfiSocketLib.inf\r
+  StdLib/UseSocketDxe/UseSocketDxe.inf\r
 \r
 ##############################################################################\r
 #\r