You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/03/05 01:23:48 UTC

[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #2982: tools/nxstyle: Verify relative path in the file header

gustavonihei commented on a change in pull request #2982:
URL: https://github.com/apache/incubator-nuttx/pull/2982#discussion_r587956360



##########
File path: tools/nxstyle.c
##########
@@ -831,6 +831,57 @@ int main(int argc, char **argv, char **envp)
                ERROR("Missing file header comment block", lineno, 1);
             }
 
+          if (lineno == 2)
+            {
+              if (line[n] == '*' && line[n + 1] == '\n')
+                {
+                  ERROR("Missing relative file path in file header", lineno,
+                        n);
+                }
+              else if (isspace(line[n + 2]))
+                {
+                  ERROR("Too many whitespaces before relative file path",
+                        lineno, n);
+                }
+              else
+                {
+                  bool file_header_mismatch = false;
+
+                  /* Checking whether g_file_name has the absolute path to
+                   * the file.
+                   * NOTE: Assuming that the project root folder name is
+                   *       "nuttx".
+                   */
+
+                  const char *root_substr = "/nuttx/";
+                  char *basedir = strstr(g_file_name, root_substr);

Review comment:
       Yes, it is one of the limitations I listed in the description.
   I haven't found a nice way of making nxstyle handle both relative and absolute file paths, since the program has no knowledge about the environment.
   One way would be to provide the project root path via program arguments, but I think it is a bad solution.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org