]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/ipc/TypedMsgHdr.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / ipc / TypedMsgHdr.cc
index b38954c3e91dc0d7820b023278458ca7cab788a3..68e011064a96a45259942ae61646098626b9480d 100644 (file)
@@ -5,13 +5,13 @@
  *
  */
 
-
-#include "config.h"
-#include <string.h>
+#include "squid.h"
 #include "protos.h"
 #include "base/TextException.h"
 #include "ipc/TypedMsgHdr.h"
 
+#include <string.h>
+
 Ipc::TypedMsgHdr::TypedMsgHdr()
 {
     xmemset(this, 0, sizeof(*this));
@@ -20,14 +20,14 @@ Ipc::TypedMsgHdr::TypedMsgHdr()
 
 Ipc::TypedMsgHdr::TypedMsgHdr(const TypedMsgHdr &tmh)
 {
-    xmemcpy(this, &tmh, sizeof(*this));
+    memcpy(this, &tmh, sizeof(*this));
     sync();
 }
 
 Ipc::TypedMsgHdr &Ipc::TypedMsgHdr::operator =(const TypedMsgHdr &tmh)
 {
     if (this != &tmh) { // skip assignment to self
-        xmemcpy(this, &tmh, sizeof(*this));
+        memcpy(this, &tmh, sizeof(*this));
         sync();
     }
     return *this;
@@ -60,8 +60,6 @@ void Ipc::TypedMsgHdr::sync()
     offset = 0;
 }
 
-
-
 int
 Ipc::TypedMsgHdr::type() const
 {
@@ -122,7 +120,7 @@ Ipc::TypedMsgHdr::getString(String &s) const
 
     Must(length <= maxSize);
     // TODO: use SBuf.reserve() instead of a temporary buffer
-    char buf[length];
+    char buf[maxSize];
     getRaw(&buf, length);
     s.limitInit(buf, length);
 }
@@ -153,10 +151,9 @@ Ipc::TypedMsgHdr::putFixed(const void *raw, size_t size)
 void
 Ipc::TypedMsgHdr::getRaw(void *raw, size_t size) const
 {
-    Must(size >= 0);
     if (size > 0) {
         Must(size <= data.size - offset);
-        xmemcpy(raw, data.raw + offset, size);
+        memcpy(raw, data.raw + offset, size);
         offset += size;
     }
 }
@@ -165,10 +162,9 @@ Ipc::TypedMsgHdr::getRaw(void *raw, size_t size) const
 void
 Ipc::TypedMsgHdr::putRaw(const void *raw, size_t size)
 {
-    Must(size >= 0);
     if (size > 0) {
         Must(size <= sizeof(data.raw) - data.size);
-        xmemcpy(data.raw + data.size, raw, size);
+        memcpy(data.raw + data.size, raw, size);
         data.size += size;
     }
 }
@@ -187,7 +183,7 @@ Ipc::TypedMsgHdr::putFd(int fd)
     cmsg->cmsg_len = CMSG_LEN(sizeof(int) * fdCount);
 
     int *fdStore = reinterpret_cast<int*>(CMSG_DATA(cmsg));
-    xmemcpy(fdStore, &fd, fdCount * sizeof(int));
+    memcpy(fdStore, &fd, fdCount * sizeof(int));
     msg_controllen = cmsg->cmsg_len;
 }
 
@@ -203,7 +199,7 @@ Ipc::TypedMsgHdr::getFd() const
     const int fdCount = 1;
     const int *fdStore = reinterpret_cast<const int*>(CMSG_DATA(cmsg));
     int fd = -1;
-    xmemcpy(&fd, fdStore, fdCount * sizeof(int));
+    memcpy(&fd, fdStore, fdCount * sizeof(int));
     return fd;
 }