changeset 1757:7ced29d424b7 draft

Minor cleanup of load_policy.
author Rob Landley <rob@landley.net>
date Fri, 27 Mar 2015 20:48:12 -0500
parents dbee4e656aa6
children f9bb7e69402d
files toys/pending/load_policy.c
diffstat 1 files changed, 3 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/toys/pending/load_policy.c	Thu Mar 26 13:25:20 2015 -0500
+++ b/toys/pending/load_policy.c	Fri Mar 27 20:48:12 2015 -0500
@@ -1,4 +1,4 @@
-/* runcon.c - Run command in specified security context
+/* load_policy.c - Load a policy file
  *
  * Copyright 2015 The Android Open Source Project
 
@@ -30,12 +30,8 @@
     close(fd);
   }
 
-  if (!policy_data) {
-    error_exit("Couldn't read %s: %s", path, strerror(errno));
-  }
-
-  if (security_load_policy(policy_data, policy_len) < 0)
-    error_exit("Couldn't load %s: %s", path, strerror(errno));
+  if (!policy_data || security_load_policy(policy_data, policy_len) < 0)
+    perror_exit("Couldn't %s %s: %s", policy_data ? "load" : "read", path);
 
   munmap(policy_data, policy_len);
 }