LCOV - code coverage report
Current view: top level - libbpfilter/cgen - jmp.c (source / functions) Coverage Total Hit
Test: coverage.lcov Lines: 80.0 % 10 8
Test Date: 2026-04-17 15:45:04 Functions: 100.0 % 1 1
Branches: 30.0 % 10 3

             Branch data     Line data    Source code
       1                 :             : /* SPDX-License-Identifier: GPL-2.0-only */
       2                 :             : /*
       3                 :             :  * Copyright (c) 2023 Meta Platforms, Inc. and affiliates.
       4                 :             :  */
       5                 :             : 
       6                 :             : #include "cgen/jmp.h"
       7                 :             : 
       8                 :             : #include <linux/bpf.h>
       9                 :             : 
      10                 :             : #include <limits.h>
      11                 :             : #include <stddef.h>
      12                 :             : #include <stdint.h>
      13                 :             : 
      14                 :             : #include <bpfilter/logger.h>
      15                 :             : 
      16                 :             : #include "cgen/program.h"
      17                 :             : 
      18                 :       34390 : void bf_jmpctx_cleanup(struct bf_jmpctx *ctx)
      19                 :             : {
      20         [ +  - ]:       34390 :     if (ctx->program) {
      21                 :             :         size_t off;
      22                 :             :         struct bpf_insn *insn =
      23                 :       34390 :             bf_vector_get(&ctx->program->img, ctx->insn_idx);
      24         [ -  + ]:       34390 :         if (!insn) {
      25         [ #  # ]:           0 :             bf_abort("jump fixup references invalid instruction index %lu",
      26                 :             :                      ctx->insn_idx);
      27                 :             :         }
      28                 :             : 
      29                 :       34390 :         off = ctx->program->img.size - ctx->insn_idx - 1U;
      30                 :             : 
      31         [ -  + ]:       34390 :         if (off > SHRT_MAX)
      32         [ #  # ]:           0 :             bf_warn("jump offset overflow: %ld", off);
      33                 :             : 
      34                 :       34390 :         insn->off = (int16_t)off;
      35                 :             :     }
      36                 :       34390 : }
        

Generated by: LCOV version 2.0-1