Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 658478da authored by Greg Kaiser's avatar Greg Kaiser
Browse files

lmkd: Adjust some buffer sizes/checks

LMKD_REPLY_MAX_SIZE was oversized by 8 bytes.  While not a cause of
bugs, this was a slight waste of space.  We're fixing this in
statslog.h (see the CL there for more details), and update this
value to keep in sync.

Additionally, KILL_OCCURRED_MSG_SIZE was undersized.  While we have
80 bytes worth of data from our memory_stat and kill_stat structs,
there's also, at a bare minimum, 4 bytes for our packet type, and
2 bytes for our process name string size.  If we don't have at
least 86 bytes here, our logKillOccurred() method will run out
of data to parse.

So in summary, this CL saves 8 bytes of memory, and will have us
now catch (rather unlikely) errors of messages between 80 and 85
bytes.

Bug: 405436516
Test: TreeHugger
Flag: EXEMPT bugfix
Change-Id: I6338a495cebb6e75034f699d83b110c950f6edc2
parent 02cefe53
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ public class LmkdConnection {
     * Used to hold the data for the statsd atoms logging
     * Must be in sync with statslog.h
     */
    private static final int LMKD_REPLY_MAX_SIZE = 222;
    private static final int LMKD_REPLY_MAX_SIZE = 214;

    // connection listener interface
    interface LmkdConnectionListener {
+4 −1
Original line number Diff line number Diff line
@@ -33,7 +33,10 @@ public final class LmkdStatsReporter {

    static final String TAG = TAG_WITH_CLASS_NAME ? "LmkdStatsReporter" : TAG_AM;

    public static final int KILL_OCCURRED_MSG_SIZE = 80;
    /**
     * This needs to be synced with statslog.h, minus MAX_TASKNAME_LEN.
     */
    public static final int KILL_OCCURRED_MSG_SIZE = 86;

    private static final int PRESSURE_AFTER_KILL = 0;
    private static final int NOT_RESPONDING = 1;