-#define posix_print_error( name, num ) \
- g_error( "file %s: line %d (%s): error %s during %s", \
- __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
- g_strerror((num)), #name )
+#define posix_check_err(err, name) G_STMT_START{ \
+ int error = (err); \
+ if (error) \
+ g_error ("file %s: line %d (%s): error '%s' during '%s'", \
+ __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
+ g_strerror (error), name); \
+ }G_STMT_END
+
+#define posix_check_cmd(cmd) posix_check_err (posix_error (cmd), #cmd)
+
+#ifdef G_ENABLE_DEBUG
+static gboolean posix_check_cmd_prio_warned = FALSE;
+# define posix_check_cmd_prio(cmd) G_STMT_START{ \
+ int err = posix_error (cmd); \
+ if (err == EPERM) \
+ { \
+ if (!posix_check_cmd_prio_warned) \
+ { \
+ posix_check_cmd_prio_warned = TRUE; \
+ g_warning ("Priorities can only be changed " \
+ "(resp. increased) by root."); \
+ } \
+ } \
+ else \
+ posix_check_err (err, #cmd); \
+ }G_STMT_END
+#else /* G_ENABLE_DEBUG */
+# define posix_check_cmd_prio(cmd) G_STMT_START{ \
+ int err = posix_error (cmd); \
+ if (err != EPERM) \
+ posix_check_err (err, #cmd); \
+ }G_STMT_END
+#endif /* G_ENABLE_DEBUG */