syntax-check: Add a rule to enforce glnx_autofd over glnx_fd_close
authorColin Walters <walters@verbum.org>
Tue, 17 Oct 2017 15:18:26 +0000 (11:18 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 17 Oct 2017 16:43:02 +0000 (16:43 +0000)
And fix the one final use.

Closes: #1280
Approved by: jlebon

cfg.mk
src/libostree/ostree-repo-commit.c

diff --git a/cfg.mk b/cfg.mk
index f6f1ce25c691b1e28d138e10646308d40adc85be..0eb05b897d46a9fa9eecfc3dd9bc5fbfb7dc3778 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -31,8 +31,12 @@ sc_glnx_errno_prefix_colon:
        @prohibit='\<glnx_throw_errno_prefix *\(.*: ",' halt="don't add trailing : for glnx_throw_errno_prefix" \
          $(_sc_search_regexp)
 
+sc_glnx_no_fd_close:
+       @prohibit='\<glnx_fd_close int' halt="Use glnx_autofd, not glnx_fd_close"       \
+         $(_sc_search_regexp)
+
 #SHELL=bash -x
 show-vc-list-except:
        @$(VC_LIST_EXCEPT)
 
-VC_LIST_ALWAYS_EXCLUDE_REGEX = ^ABOUT-NLS|maint.mk|*.gpg|*.sig|.xz$$
+VC_LIST_ALWAYS_EXCLUDE_REGEX = ^ABOUT-NLS|cfg.mk|maint.mk|*.gpg|*.sig|.xz$$
index 164003f7b86c962c11d73f8e687639f6a2d66211..e1649c1dd24401fba80593e9c0fc64e23145742c 100644 (file)
@@ -821,7 +821,7 @@ adopt_and_commit_regfile (OstreeRepo   *self,
   ot_checksum_init (&hasher);
   ot_checksum_update_bytes (&hasher, header);
 
-  glnx_fd_close int fd = -1;
+  glnx_autofd int fd = -1;
   if (!glnx_openat_rdonly (dfd, name, FALSE, &fd, error))
     return FALSE;