You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2020/05/04 22:55:25 UTC

[trafficserver] branch master updated (287ee46 -> a1fb39e)

This is an automated email from the ASF dual-hosted git repository.

bcall pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.


    from 287ee46  Update expired test certificates for cert_update
     new be58405  GCC 10 fixes - simple fixes.
     new a1fb39e  GCC 10: Update traffic_via to use string_view to avoid compile errors.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 iocore/cache/P_CacheTest.h     |  2 +-
 proxy/http/HttpTunnel.cc       |  4 +--
 src/traffic_via/traffic_via.cc | 81 +++++++++++++++++-------------------------
 src/tscore/Arena.cc            |  4 +--
 4 files changed, 38 insertions(+), 53 deletions(-)


[trafficserver] 01/02: GCC 10 fixes - simple fixes.

Posted by bc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit be584052e2ac2b0867e64d3d743f92880ddb696d
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Fri May 1 11:53:23 2020 -0500

    GCC 10 fixes - simple fixes.
---
 iocore/cache/P_CacheTest.h | 2 +-
 proxy/http/HttpTunnel.cc   | 4 ++--
 src/tscore/Arena.cc        | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/iocore/cache/P_CacheTest.h b/iocore/cache/P_CacheTest.h
index ba9814e..47f0cfd 100644
--- a/iocore/cache/P_CacheTest.h
+++ b/iocore/cache/P_CacheTest.h
@@ -44,7 +44,7 @@ struct PinnedDocTable : public Continuation {
   int remove(CacheKey *key);
   int cleanup(int event, Event *e);
 
-  PinnedDocTable() : Continuation(new_ProxyMutex()) { memset(bucket, 0, sizeof(Queue<PinnedDocEntry>) * PINNED_DOC_TABLE_SIZE); }
+  PinnedDocTable() : Continuation(new_ProxyMutex()) { ink_zero(bucket); }
 };
 
 struct CacheTestHost {
diff --git a/proxy/http/HttpTunnel.cc b/proxy/http/HttpTunnel.cc
index 2b7f820..4fbac85 100644
--- a/proxy/http/HttpTunnel.cc
+++ b/proxy/http/HttpTunnel.cc
@@ -479,8 +479,8 @@ HttpTunnel::reset()
 
   num_producers = 0;
   num_consumers = 0;
-  memset(consumers, 0, sizeof(consumers));
-  memset(producers, 0, sizeof(producers));
+  ink_zero(consumers);
+  ink_zero(producers);
 }
 
 void
diff --git a/src/tscore/Arena.cc b/src/tscore/Arena.cc
index 81af84c..e26a20a 100644
--- a/src/tscore/Arena.cc
+++ b/src/tscore/Arena.cc
@@ -48,8 +48,8 @@ blk_alloc(int size)
   }
 
   blk->next          = nullptr;
-  blk->m_heap_end    = &blk->data[size];
-  blk->m_water_level = &blk->data[0];
+  blk->m_heap_end    = blk->data + size;
+  blk->m_water_level = blk->data;
 
   return blk;
 }


[trafficserver] 02/02: GCC 10: Update traffic_via to use string_view to avoid compile errors.

Posted by bc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit a1fb39e32515b779473fae9fa325b3f7f510c22b
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Fri May 1 14:28:54 2020 -0500

    GCC 10: Update traffic_via to use string_view to avoid compile errors.
---
 src/traffic_via/traffic_via.cc | 81 +++++++++++++++++-------------------------
 1 file changed, 33 insertions(+), 48 deletions(-)

diff --git a/src/traffic_via/traffic_via.cc b/src/traffic_via/traffic_via.cc
index 197032b..65fb617 100644
--- a/src/traffic_via/traffic_via.cc
+++ b/src/traffic_via/traffic_via.cc
@@ -24,11 +24,11 @@
 #include "tscore/ink_platform.h"
 #include "tscore/ink_args.h"
 #include "tscore/I_Version.h"
-#include "tscore/Tokenizer.h"
-#include "tscore/TextBuffer.h"
 #include "mgmtapi.h"
 #include <cstdio>
 #include <cstring>
+#include <iostream>
+#include <string_view>
 #include "tscore/Regex.h"
 
 /// XXX Use DFA or Regex wrappers?
@@ -43,11 +43,11 @@
 static AppVersionInfo appVersionInfo;
 
 struct VIA {
-  VIA(const char *t) : title(t), next(nullptr) { memset(viaData, 0, sizeof(viaData)); }
+  VIA(const char *t) : title(t) {}
   ~VIA() { delete next; }
   const char *title;
-  const char *viaData[128];
-  VIA *next;
+  const char *viaData[128] = {}; // zero initialize
+  VIA *next                = nullptr;
 };
 
 // Function to get via header table for every field/category in the via header
@@ -186,7 +186,7 @@ standardViaLookup(char flag)
 
 // Function to print via header
 static void
-printViaHeader(const char *header)
+printViaHeader(std::string_view header)
 {
   VIA *viaTable = nullptr;
   VIA *viaEntry = nullptr;
@@ -195,22 +195,22 @@ printViaHeader(const char *header)
   printf("Via Header Details:\n");
 
   // Loop through input via header flags
-  for (const char *c = header; *c; ++c) {
-    if ((*c == ':') || (*c == ';')) {
+  for (char c : header) {
+    if ((c == ':') || (c == ';')) {
       isDetail = true;
       continue;
     }
 
-    if (islower(*c)) {
+    if (islower(c)) {
       // Get the via header table
       delete viaTable;
-      viaEntry = viaTable = isDetail ? detailViaLookup(*c) : standardViaLookup(*c);
+      viaEntry = viaTable = isDetail ? detailViaLookup(c) : standardViaLookup(c);
     } else {
       // This is a one of the sequence of (uppercase) VIA codes.
       if (viaEntry) {
+        unsigned char idx = c;
         printf("%-55s:", viaEntry->title);
-        printf("%s\n", viaEntry->viaData[static_cast<unsigned char>(*c)] ? viaEntry->viaData[static_cast<unsigned char>(*c)] :
-                                                                           "Invalid sequence");
+        printf("%s\n", viaEntry->viaData[idx] ? viaEntry->viaData[idx] : "Invalid sequence");
         viaEntry = viaEntry->next;
       }
     }
@@ -220,32 +220,29 @@ printViaHeader(const char *header)
 
 // Check validity of via header and then decode it
 static TSMgmtError
-decodeViaHeader(const char *str)
+decodeViaHeader(std::string_view text)
 {
-  size_t viaHdrLength = strlen(str);
-  char tmp[viaHdrLength + 2];
-  char *Via = tmp;
-
-  memcpy(Via, str, viaHdrLength);
-  Via[viaHdrLength] = '\0'; // null terminate
-
   // Via header inside square brackets
-  if (Via[0] == '[' && Via[viaHdrLength - 1] == ']') {
-    viaHdrLength = viaHdrLength - 2;
-    Via++;
-    Via[viaHdrLength] = '\0'; // null terminate the string after trimming
+  if (!text.empty() && text.front() == '[' && text.back() == ']') {
+    text.remove_prefix(1);
+    text.remove_suffix(1);
+  }
+  if (text.empty()) {
+    return TS_ERR_FAIL;
   }
 
-  printf("Via header is [%s], Length is %zu\n", Via, viaHdrLength);
+  printf("Via header is [%.*s], Length is %zu\n", int(text.size()), text.data(), text.size());
 
-  if (viaHdrLength == 5) {
-    Via = strcat(Via, " "); // Add one space character before decoding via header
-    ++viaHdrLength;
+  char extender[6];
+  if (text.size() == 5) { // add a trailing space in this case.
+    memcpy(extender, text.data(), text.size());
+    extender[5] = ' ';
+    text        = std::string_view{extender, 6};
   }
 
-  if (viaHdrLength == 22 || viaHdrLength == 6) {
+  if (text.size() == 22 || text.size() == 6) {
     // Decode via header
-    printViaHeader(Via);
+    printViaHeader(text);
     return TS_ERR_OKAY;
   }
   // Invalid header size, come out.
@@ -269,8 +266,7 @@ filterViaHeader()
   int i;
   const char *viaPattern =
     R"(\[([ucsfpe]+[^\]]+)\])"; // Regex to match via header with in [] which can start with character class ucsfpe
-  char *viaHeaderString;
-  char viaHeader[1024];
+  std::string line;
 
   // Compile PCRE via header pattern
   compiledReg = pcre_compile(viaPattern, 0, &err, &errOffset, nullptr);
@@ -281,15 +277,9 @@ filterViaHeader()
   }
 
   // Read all lines from stdin
-  while (fgets(viaHeader, sizeof(viaHeader), stdin)) {
-    // Trim new line character and null terminate it
-    char *newLinePtr = strchr(viaHeader, '\n');
-    if (newLinePtr) {
-      *newLinePtr = '\0';
-    }
+  while (std::getline(std::cin, line)) {
     // Match for via header pattern
-    pcreExecCode = pcre_exec(compiledReg, extraReg, viaHeader, static_cast<int>(sizeof(viaHeader)), 0, 0, subStringVector,
-                             SUBSTRING_VECTOR_COUNT);
+    pcreExecCode = pcre_exec(compiledReg, extraReg, line.data(), line.size(), 0, 0, subStringVector, SUBSTRING_VECTOR_COUNT);
 
     // Match failed, don't worry. Continue to next line.
     if (pcreExecCode < 0) {
@@ -304,14 +294,9 @@ filterViaHeader()
 
     // Loop based on number of matches found
     for (i = 1; i < pcreExecCode; i++) {
-      // Point to beginning of matched substring
-      char *subStringBegin = viaHeader + subStringVector[2 * i];
-      // Get length of matched substring
-      int subStringLen = subStringVector[2 * i + 1] - subStringVector[2 * i];
-      viaHeaderString  = subStringBegin;
-      sprintf(viaHeaderString, "%.*s", subStringLen, subStringBegin);
+      std::string_view match{line.data() + subStringVector[2 * i], size_t(subStringVector[2 * i + 1] - subStringVector[2 * i])};
       // Decode matched substring
-      decodeViaHeader(viaHeaderString);
+      decodeViaHeader(match);
     }
   }
   return TS_ERR_OKAY;
@@ -338,7 +323,7 @@ main(int /* argc ATS_UNUSED */, const char **argv)
       // Filter arguments provided from stdin
       status = filterViaHeader();
     } else {
-      status = decodeViaHeader(file_arguments[i]);
+      status = decodeViaHeader(std::string_view{file_arguments[i], strlen(file_arguments[i])});
     }
 
     if (status != TS_ERR_OKAY) {