Browse Source

Silenced more of aldot's warnings

Flags used:
-Wall -Wextra -Wshadow -Wwrite-strings -Wundef -Wstrict-prototypes
-Wunused -Wunused-parameter -Wunused-function -Wunused-value
-Wmissing-prototypes -Wmissing-declarations -Wold-style-definition
Christopher Haster 7 years ago
parent
commit
dc513b172f
2 changed files with 9 additions and 5 deletions
  1. 7 3
      lfs.c
  2. 2 2
      tests/template.fmt

+ 7 - 3
lfs.c

@@ -1016,6 +1016,7 @@ int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) {
 }
 
 lfs_soff_t lfs_dir_tell(lfs_t *lfs, lfs_dir_t *dir) {
+    (void)lfs;
     return dir->pos;
 }
 
@@ -1669,7 +1670,8 @@ int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
         return LFS_ERR_INVAL;
     }
 
-    if (size < lfs_file_size(lfs, file)) {
+    lfs_off_t oldsize = lfs_file_size(lfs, file);
+    if (size < oldsize) {
         // need to flush since directly changing metadata
         int err = lfs_file_flush(lfs, file);
         if (err) {
@@ -1686,11 +1688,11 @@ int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
 
         file->size = size;
         file->flags |= LFS_F_DIRTY;
-    } else if (size > lfs_file_size(lfs, file)) {
+    } else if (size > oldsize) {
         lfs_off_t pos = file->pos;
 
         // flush+seek if not already at end
-        if (file->pos != lfs_file_size(lfs, file)) {
+        if (file->pos != oldsize) {
             int err = lfs_file_seek(lfs, file, 0, SEEK_END);
             if (err) {
                 return err;
@@ -1716,6 +1718,7 @@ int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
 }
 
 lfs_soff_t lfs_file_tell(lfs_t *lfs, lfs_file_t *file) {
+    (void)lfs;
     return file->pos;
 }
 
@@ -1729,6 +1732,7 @@ int lfs_file_rewind(lfs_t *lfs, lfs_file_t *file) {
 }
 
 lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file) {
+    (void)lfs;
     if (file->flags & LFS_F_WRITING) {
         return lfs_max(file->pos, file->size);
     } else {

+ 2 - 2
tests/template.fmt

@@ -37,8 +37,8 @@ static void test_assert(const char *file, unsigned line,
 
 
 // utility functions for traversals
-static int __attribute__((used)) test_count(void *p,
-	lfs_block_t b __attribute__((unused))) {{
+static int __attribute__((used)) test_count(void *p, lfs_block_t b) {{
+    (void)b;
     unsigned *u = (unsigned*)p;
     *u += 1;
     return 0;