[Rpm-maint] [rpm-software-management/rpm] [WIP] Added fapolicyd plugin (#1475)

Panu Matilainen notifications at github.com
Wed Jan 27 13:49:07 UTC 2021


@pmatilai commented on this pull request.



> +        /* send a signal that transaction is over */
+        (void) write_fifo(&fapolicyd_state, "1\n");
+        /* flush cache */
+        (void) write_fifo(&fapolicyd_state, "2\n");
+    }
+
+ end:
+    return RPMRC_OK;
+}
+
+static rpmRC fapolicyd_scriptlet_pre(rpmPlugin plugin, const char *s_name,
+                                     int type)
+{
+    if (fapolicyd_state.fd > 0 &&
+        fapolicyd_state.changed_files > 0 &&
+        fapolicyd_state.installed_package ) {

The if condition is on same indentation level as the following code, making it hard to see where the condition stops and code starts. There are various ways to deal with that, my favourite generally is moving (parts of) the condition into a helper variable, with well-named variables this has the effect of making the code self-documenting as well. For example:
```
    int need_flush = (fapolicyd_state.changed_files > 0) && fapolicyd_state.installed_package;
    if (fapolicyd_state.fd > 0 && need_flush) {
        ...
    }
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/1475#pullrequestreview-577351791
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20210127/55534646/attachment.html>


More information about the Rpm-maint mailing list