TimJTi commented on code in PR #2178:
URL: https://github.com/apache/nuttx-apps/pull/2178#discussion_r1383780934


##########
system/settings/storage_bin.c:
##########
@@ -0,0 +1,246 @@
+/****************************************************************************
+ * apps/system/settings/storage_bin.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "system/settings.h"
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <nuttx/crc32.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <nuttx/config.h>
+#include <sys/types.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define VALID          0x600d
+#define BUFFER_SIZE    256     /* Note alignment for Flash writes! */
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+FAR static setting_t *getsetting(char *key);
+extern state_t g_settings;
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: load_bin
+ *
+ * Description:
+ *    Loads binary data from a storage file.
+ *
+ * Input Parameters:
+ *    file             - the filename of the storage to use
+ *
+ * Returned Value:
+ *   Success or negated failure code
+ *
+ ****************************************************************************/
+
+int load_bin(FAR char *file)
+{
+  static int fd;
+  int i;
+  int ret = OK;
+  uint16_t valid;
+  uint16_t count;
+
+  fd = open(file, O_RDONLY);
+  if (fd < 0)
+    {
+      return -ENOENT;
+    }
+
+  valid = 0;
+  read(fd, &valid, sizeof(uint16_t));
+
+  if (valid != VALID)
+    {
+      goto abort; /* Just exit - the settings aren't valid. What to do? */
+    }
+
+  count = 0;
+  read(fd, &count, sizeof(uint16_t));
+
+  uint32_t calc_crc = 0;
+  uint32_t exp_crc = 0;

Review Comment:
   Agreed. Many I fixed, but missed this one!



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

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

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

Reply via email to