8219562: Line of code in osContainer_linux.cpp L102 appears unreachable
authorbobv
Tue, 19 Mar 2019 12:00:54 -0400
changeset 54191 da7f6755ba71
parent 54189 dfde3bb48c03
child 54192 d909d0a883c4
8219562: Line of code in osContainer_linux.cpp L102 appears unreachable Reviewed-by: rriggs, sgehwolf
src/hotspot/os/linux/osContainer_linux.cpp
--- a/src/hotspot/os/linux/osContainer_linux.cpp	Tue Mar 19 10:47:17 2019 -0400
+++ b/src/hotspot/os/linux/osContainer_linux.cpp	Tue Mar 19 12:00:54 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -99,14 +99,14 @@
             buf[MAXPATHLEN-1] = '\0';
             _path = os::strdup(buf);
           } else {
-            char *p = strstr(_root, cgroup_path);
+            char *p = strstr(cgroup_path, _root);
             if (p != NULL && p == _root) {
               if (strlen(cgroup_path) > strlen(_root)) {
                 int buflen;
                 strncpy(buf, _mount_point, MAXPATHLEN);
                 buf[MAXPATHLEN-1] = '\0';
                 buflen = strlen(buf);
-                if ((buflen + strlen(cgroup_path)) > (MAXPATHLEN-1)) {
+                if ((buflen + strlen(cgroup_path) - strlen(_root)) > (MAXPATHLEN-1)) {
                   return;
                 }
                 strncat(buf, cgroup_path + strlen(_root), MAXPATHLEN-buflen);