You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/04/11 23:31:15 UTC

[4/4] mesos git commit: Removed unnecesary break statements in local approver.

Removed unnecesary break statements in local approver.

Removes `break` statements located in lines following a `return`
statement since they are effectively unreachable code, don't improve
readability nor make the code cleaner.

Review: https://reviews.apache.org/r/58292/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/76d42c3b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/76d42c3b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/76d42c3b

Branch: refs/heads/master
Commit: 76d42c3bb8404b68656dfff4ed31cff9750f3e65
Parents: 8e15963
Author: Alexander Rojas <al...@mesosphere.io>
Authored: Mon Apr 10 18:03:10 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Apr 11 16:31:06 2017 -0700

----------------------------------------------------------------------
 src/common/validation.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/76d42c3b/src/common/validation.cpp
----------------------------------------------------------------------
diff --git a/src/common/validation.cpp b/src/common/validation.cpp
index 544d3a0..9c4f1de 100644
--- a/src/common/validation.cpp
+++ b/src/common/validation.cpp
@@ -16,6 +16,8 @@
 
 #include "common/validation.hpp"
 
+#include <limits.h>
+
 #include <algorithm>
 #include <cctype>
 
@@ -37,13 +39,19 @@ Option<Error> validateID(const string& id)
     return Error("ID must not be empty");
   }
 
+  if (id.length() > NAME_MAX) {
+    return Error(
+        "ID must not be greater than " +
+        stringify(NAME_MAX) + " characters");
+  }
+
   // The ID cannot be exactly these special path components.
   if (id == "." || id == "..") {
     return Error("'" + id + "' is disallowed");
   }
 
   // Rules on invalid characters in the ID:
-  // - Control charaters are obviously not allowed.
+  // - Control characters are obviously not allowed.
   // - Slashes are disallowed as IDs are likely mapped to directories in Mesos.
   auto invalidCharacter = [](char c) {
     return iscntrl(c) ||


Re: [4/4] mesos git commit: Removed unnecesary break statements in local approver.

Posted by Jie Yu <yu...@gmail.com>.
oops. I think I might break something. I don't know why this happened :(
Let me try to fix it.

On Tue, Apr 11, 2017 at 4:31 PM, <ji...@apache.org> wrote:

> Removed unnecesary break statements in local approver.
>
> Removes `break` statements located in lines following a `return`
> statement since they are effectively unreachable code, don't improve
> readability nor make the code cleaner.
>
> Review: https://reviews.apache.org/r/58292/
>
>
> Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
> Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/76d42c3b
> Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/76d42c3b
> Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/76d42c3b
>
> Branch: refs/heads/master
> Commit: 76d42c3bb8404b68656dfff4ed31cff9750f3e65
> Parents: 8e15963
> Author: Alexander Rojas <al...@mesosphere.io>
> Authored: Mon Apr 10 18:03:10 2017 -0700
> Committer: Jie Yu <yu...@gmail.com>
> Committed: Tue Apr 11 16:31:06 2017 -0700
>
> ----------------------------------------------------------------------
>  src/common/validation.cpp | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/mesos/blob/76d42c3b/
> src/common/validation.cpp
> ----------------------------------------------------------------------
> diff --git a/src/common/validation.cpp b/src/common/validation.cpp
> index 544d3a0..9c4f1de 100644
> --- a/src/common/validation.cpp
> +++ b/src/common/validation.cpp
> @@ -16,6 +16,8 @@
>
>  #include "common/validation.hpp"
>
> +#include <limits.h>
> +
>  #include <algorithm>
>  #include <cctype>
>
> @@ -37,13 +39,19 @@ Option<Error> validateID(const string& id)
>      return Error("ID must not be empty");
>    }
>
> +  if (id.length() > NAME_MAX) {
> +    return Error(
> +        "ID must not be greater than " +
> +        stringify(NAME_MAX) + " characters");
> +  }
> +
>    // The ID cannot be exactly these special path components.
>    if (id == "." || id == "..") {
>      return Error("'" + id + "' is disallowed");
>    }
>
>    // Rules on invalid characters in the ID:
> -  // - Control charaters are obviously not allowed.
> +  // - Control characters are obviously not allowed.
>    // - Slashes are disallowed as IDs are likely mapped to directories in
> Mesos.
>    auto invalidCharacter = [](char c) {
>      return iscntrl(c) ||
>
>