• mdempsky's avatar
    Decouple CodeGen from ErrorCode · a5f20640
    mdempsky authored
    CodeGen's only dependency on ErrorCode was one MakeInstruction()
    overload, which can be removed by making the caller responsible for
    converting the ErrorCode to a BPF_RET'able value. Fortunately, there
    are only two uses of this function:
    
    1. SandboxBPF::RetExpression() which is easily fixed by simply calling
    ErrorCode::err() to get the ErrorCode's error value.
    
    2. codegen_unittest.cc which is merely testing the BPF code generator,
    and so any return values will do: no need to be seccomp-bpf return
    values... so just replace them with simple integer values.  (While
    here, change a few bare "BPF_RET" arguments to "BPF_RET + BPF_K" just
    to be consistent.)
    
    After this CL, CodeGen focuses solely on assembling programs for the
    abstract BPF machine, while higher-level abstractions (primarily
    SandboxBPF) are responsible for using it in a way that's semantically
    meaningful for seccomp-bpf.
    
    BUG=414363
    
    Review URL: https://codereview.chromium.org/576673003
    
    Cr-Commit-Position: refs/heads/master@{#295192}
    a5f20640
codegen.cc 29.8 KB