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/06/04 13:08:48 UTC

[GitHub] [incubator-nuttx] acassis commented on a change in pull request #3848: Syslog file rotations number is configurable.

acassis commented on a change in pull request #3848:
URL: https://github.com/apache/incubator-nuttx/pull/3848#discussion_r645555432



##########
File path: drivers/syslog/syslog_filechannel.c
##########
@@ -85,28 +88,44 @@ static void log_rotate(FAR const char *log_file)
       return;
     }
 
-  /* Construct the backup file name. */
+  /* Rotated file names. */
 
-  backup_file = malloc(strlen(log_file) + 3);
-  if (backup_file == NULL)
+  name_size = strlen(log_file) + 8;
+  rotate_to = malloc(name_size);
+  rotate_from = malloc(name_size);
+  if ((rotate_to == NULL) || (rotate_from == NULL))
     {
-      return;
+      goto end;
     }
 
-  sprintf(backup_file, "%s.0", log_file);
+  /* Rotate the logs. */
+
+  for (int i = (CONFIG_SYSLOG_FILE_ROTATIONS - 1); i > 0; i--)

Review comment:
       Please declare "int i" at the top of the function, NuttX common code needs to be C89 compatible, only Arch specific code doesn't need to follow it.




-- 
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