ronantakizawa/codereview-bench huggingface dataset:
Repository: anuraghazra/github-readme-stats
File: tests/calculateRank.test.js (JavaScript)

Code before:
  it("new user gets B rank", () => {
    expect(
      calculateRank({
        totalRepos: 0,
        totalCommits: 0,
        contributions: 0,
        followers: 0,
        prs: 0,
        issues: 0,
        stargazers: 0,
      }),
    ).toStrictEqual({level: "B", score: 100.});
  });

  it("average user gets A rank", () => {
    expect(
      calculateRank({
        totalRepos: 10,
        totalCommits: 500,
        contributions: 500,
        followers: 50,
        prs: 12,
        issues: 13,
        stargazers: 100,
      }),
    ).toStrictEqual({"A", score: 50.});
  });

  it("Linus Torvalds gets S+ rank", () => {
    expect(
      calculateRank({
        totalRepos: 4,
        totalCommits: 20000,
        contributions: 20000,
        followers: 132000,
        prs: 71,
        issues: 2,
        stargazers: 109100,
      }),
    ).toStrictEqual({level: "S+", score: 1.8875322153011722});
  });
});


Review comment (suggestion):
```suggestion
    ).toStrictEqual({level: "A", score: 50.});
```

Otherwise, the tests will throw a `Unexpected token (30:24)` error.

Code after:
  it("new user gets B rank", () => {
    expect(
      calculateRank({
        all_commits: false,
        commits: 0,
        prs: 0,
        issues: 0,
        repos: 0,
        stars: 0,
        followers: 0,
      }),
    ).toStrictEqual({ level: "B", score: 100 });
  });

  it("average user gets A rank", () => {
    expect(
      calculateRank({
        all_commits: false,
        commits: 250,
        prs: 50,
        issues: 25,
        repos: 0,
        stars: 250,
        followers: 25,
      }),
    ).toStrictEqual({ level: "A", score: 50 });
  });

  it("average user gets A rank (include_all_commits)", () => {
    expect(
      calculateRank({
        all_commits: true,
        commits: 1000,
        prs: 50,
        issues: 25,
        repos: 0,
        stars: 250,
        followers: 25,
      }),
    ).toStrictEqual({ level: "A", score: 50 });
  });

  it("more than average user gets A+ rank", () => {
    expect(
      calculateRank({
        all_commits: false,
        commits: 500,
        prs: 100,
        issues: 50,
        repos: 0,
        stars: 500,
Repository: anuraghazra/github-readme-stats
File: src/cards/types.d.ts (TypeScript)

Code before:
type ThemeNames = keyof typeof import("../../themes/index.js");
type RankIcon = "default" | "github" | "percentile";

export type CommonOptions = {
  title_color: string;
  icon_color: string;
  text_color: string;
  bg_color: string;
  theme: ThemeNames;
  border_radius: number;
  border_color: string;
  locale: string;
  hide_border: boolean;
};

export type StatCardOptions = CommonOptions & {
  hide: string[];
  show_icons: boolean;
  hide_title: boolean;
  card_width: number;
  hide_rank: boolean;
  include_all_commits: boolean;
  year?: number;
  line_height: number | string;
  custom_title: string;
  disable_animations: boolean;
  number_format: string;
  ring_color: string;
  text_bold: boolean;
  rank_icon: RankIcon;
  show: string[];
};

export type RepoCardOptions = CommonOptions & {
  show_owner: boolean;
  description_lines_count: number;
};

export type TopLangOptions = CommonOptions & {
  hide_title: boolean;
  card_width: number;
  hide: string[];
  layout: "compact" | "normal" | "donut" | "donut-vertical" | "pie";
  custom_title: string;
  langs_count: number;
  disable_animations: boolean;
  hide_progress: boolean;
};

Review comment (suggestion):
I think that it is not a place to indicate that query parameter is optional, since `StatsCardOptions` will be wrapped into `Partial<...>` on https://github.com/anuraghazra/github-readme-stats/blob/master/src/cards/stats-card.js#L199. 

```suggestion
  year: number;
```

Code after:
type ThemeNames = keyof typeof import("../../themes/index.js");
type RankIcon = "default" | "github" | "percentile";

export type CommonOptions = {
  title_color: string;
  icon_color: string;
  text_color: string;
  bg_color: string;
  theme: ThemeNames;
  border_radius: number;
  border_color: string;
  locale: string;
  hide_border: boolean;
};

export type StatCardOptions = CommonOptions & {
  hide: string[];
  show_icons: boolean;
  hide_title: boolean;
  card_width: number;
  hide_rank: boolean;
  include_all_commits: boolean;
  commits_year: number;
  line_height: number | string;
  custom_title: string;
  disable_animations: boolean;
  number_format: string;
  ring_color: string;
  text_bold: boolean;
  rank_icon: RankIcon;
  show: string[];
};

export type RepoCardOptions = CommonOptions & {
  show_owner: boolean;
  description_lines_count: number;
};

export type TopLangOptions = CommonOptions & {
  hide_title: boolean;
  card_width: number;
  hide: string[];
  layout: "compact" | "normal" | "donut" | "donut-vertical" | "pie";
  custom_title: string;
  langs_count: number;
  disable_animations: boolean;
  hide_progress: boolean;
  stats_format: "percentages" | "bytes";
Repository: anuraghazra/github-readme-stats
File: tests/fetchStats.test.js (JavaScript)

Code before:
        },
      },
    },
  },
};

const error = {
  errors: [
    {
      type: "NOT_FOUND",
      path: ["user"],
      locations: [],
      message: "Could not resolve to a User with the login of 'noname'.",
    },
  ],
};

const mock = new MockAdapter(axios);

/**
 * Mocks the GraphQL API based on certain conditions.
 *
 * @param {*} config Axios config object.
 * @returns Axios response object.
 */

beforeEach(() => {
  process.env.FETCH_MULTI_PAGE_STARS = "false"; // Set to `false` to fetch only one page of stars.
  mock.onPost("https://api.github.com/graphql").reply((cfg) => {
    let req = JSON.parse(cfg.data);

    if (
      req.variables &&
      req.variables.startTime &&
      req.variables.startTime.startsWith("2003")
    ) {
      return [200, data_year2003];
    }
    return [
      200,
      req.query.includes("contributionsCollection") ? data_stats : data_repo,
    ];
  });
});

afterEach(() => {
  mock.reset();
});

describe("Test fetchStats", () => {
  it("should fetch correct stats", async () => {

Review comment (suggestion):
I think we don't need that blank line

```suggestion
```

Code after:
          hasNextPage: true,
          endCursor: "cursor",
        },
      },
    },
  },
};

const error = {
  errors: [
    {
      type: "NOT_FOUND",
      path: ["user"],
      locations: [],
      message: "Could not resolve to a User with the login of 'noname'.",
    },
  ],
};

const mock = new MockAdapter(axios);

beforeEach(() => {
  process.env.FETCH_MULTI_PAGE_STARS = "false"; // Set to `false` to fetch only one page of stars.
  mock.onPost("https://api.github.com/graphql").reply((cfg) => {
    let req = JSON.parse(cfg.data);

    if (
      req.variables &&
      req.variables.startTime &&
      req.variables.startTime.startsWith("2003")
    ) {
      return [200, data_year2003];
    }
    return [
      200,
      req.query.includes("totalCommitContributions") ? data_stats : data_repo,
    ];
  });
});

afterEach(() => {
  mock.reset();
});

describe("Test fetchStats", () => {
  it("should fetch correct stats", async () => {
    let stats = await fetchStats("anuraghazra");
    const rank = calculateRank({
      all_commits: false,
      commits: 100,
      prs: 300,
Repository: anuraghazra/github-readme-stats
File: src/fetchers/wakatime-fetcher.js (JavaScript)

Code before:
import axios from "axios";
import { MissingParamError } from "../common/utils.js";

/**
 * WakaTime data fetcher.
 *
 * @param {{username: string, api_domain: string}} props Fetcher props.
 * @returns {Promise<WakaTimeData>} WakaTime data response.
 */
const fetchWakatimeStats = async ({ username, api_domain }) => {
  if (!username) throw new MissingParamError(["username"]);

  // Loop through available ranges to get user data.
  for (const range of ["all_time", "last_7_days", "last_year"]) {
    try {
      const { data } = await axios.get(
        `https://${
          api_domain ? api_domain.replace(/\/$/gi, "") : "wakatime.com"
        }/api/v1/users/${username}/stats/${range}?is_including_today=true`,
      );

      return data.data;
    } catch (err) {
      if (err.response.status === 403 && range !== "last_year") {
        continue;
      } else if (err.response.status < 200 || err.response.status > 299) {
        throw new Error(i18n.t("wakatimecard.nouser"));
      }
      throw err;
    }
  }
};

export { fetchWakatimeStats };
export default fetchWakatimeStats;


Review comment (suggestion):
Perhaps swap the order of "last_year" and "last_7_days", since if the user sets the preference to option "Last year", we may be accessible to both "last_year" and the narrower range "last_7_days", when in fact the user might want to show the range "last_year". Therefore an order from a wider range to a narrower one may sound better.

Code after:
import axios from "axios";
import { CustomError, MissingParamError } from "../common/utils.js";
import { I18n } from "../common/I18n.js";

/**
 * WakaTime data fetcher.
 *
 * @param {{username: string, api_domain: string }} props Fetcher props.
 * @returns {Promise<WakaTimeData>} WakaTime data response.
 */
const fetchWakatimeStats = async ({ username, api_domain }) => {
  if (!username) throw new MissingParamError(["username"]);

  try {
    const { data } = await axios.get(
      `https://${
        api_domain ? api_domain.replace(/\/$/gi, "") : "wakatime.com"
      }/api/v1/users/${username}/stats?is_including_today=true`,
    );

    return data.data;
  } catch (err) {
    if (err.response.status < 200 || err.response.status > 299) {
      throw new CustomError(
        `Could not resolve to a User with the login of '${username}'`,
        "WAKATIME_USER_NOT_FOUND",
      );
    }
    throw err;
  }
};

export { fetchWakatimeStats };
export default fetchWakatimeStats;
Repository: anuraghazra/github-readme-stats
File: src/fetchers/wakatime-fetcher.js (JavaScript)

Code before:
import axios from "axios";
import { MissingParamError } from "../common/utils.js";

/**
 * WakaTime data fetcher.
 *
 * @param {{username: string, api_domain: string}} props Fetcher props.
 * @returns {Promise<WakaTimeData>} WakaTime data response.
 */
const fetchWakatimeStats = async ({ username, api_domain }) => {
  if (!username) throw new MissingParamError(["username"]);

  // Loop through available ranges to get user data.
  for (const range of ["all_time", "last_year", "last_7_days"]) {
    try {
      const { data } = await axios.get(
        `https://${
          api_domain ? api_domain.replace(/\/$/gi, "") : "wakatime.com"
        }/api/v1/users/${username}/stats/${range}?is_including_today=true`,
      );

      return data.data;
    } catch (err) {
      if (err.response.status === 403 && range !== "last_year") {
        continue;
      } else if (err.response.status < 200 || err.response.status > 299) {
        throw new Error(i18n.t("wakatimecard.nouser"));
      }
      throw err;
    }
  }
};

export { fetchWakatimeStats };
export default fetchWakatimeStats;


Review comment (performance):
Instead of a loop you can also fetch https://wakatime.com/api/v1/users/current and use `public_profile_time_range` to find the user's public profile range. It might end up being the same performance, sometimes taking one request more and sometimes saving one request depending on how many tries before this loop finds the right range.

Code after:
import axios from "axios";
import { CustomError, MissingParamError } from "../common/utils.js";
import { I18n } from "../common/I18n.js";

/**
 * WakaTime data fetcher.
 *
 * @param {{username: string, api_domain: string }} props Fetcher props.
 * @returns {Promise<WakaTimeData>} WakaTime data response.
 */
const fetchWakatimeStats = async ({ username, api_domain }) => {
  if (!username) throw new MissingParamError(["username"]);

  try {
    const { data } = await axios.get(
      `https://${
        api_domain ? api_domain.replace(/\/$/gi, "") : "wakatime.com"
      }/api/v1/users/${username}/stats?is_including_today=true`,
    );

    return data.data;
  } catch (err) {
    if (err.response.status < 200 || err.response.status > 299) {
      throw new CustomError(
        `Could not resolve to a User with the login of '${username}'`,
        "WAKATIME_USER_NOT_FOUND",
      );
    }
    throw err;
  }
};

export { fetchWakatimeStats };
export default fetchWakatimeStats;
Repository: anuraghazra/github-readme-stats
File: src/translations.js (JavaScript)

Code before:
    fi: "Viime vuosi",
    fr: "L'année dernière",
    hi: "पिछले साल",
    hu: "Tavaly",
    it: "L'anno scorso",
    ja: "昨年",
    kr: "작년",
    nl: "Vorig jaar",
    "pt-pt": "Ano passado",
    "pt-br": "Ano passado",
    np: "गत वर्ष",
    el: "Πέρυσι",
    ro: "Anul trecut",
    ru: "За прошлый год",
    "uk-ua": "За минулий рік",
    id: "Tahun lalu",
    ml: "കഴിഞ്ഞ വർഷം",
    my: "Tahun lepas",
    sk: "Minulý rok",
    tr: "Geçen yıl",
    pl: "W zeszłym roku",
    uz: "O'tgan yil",
    vi: "Năm ngoái",
    se: "Förra året",
    th: "ปีที่แล้ว",
    "sr-Cyrl": "Прошла год.",
    "sr-Latn": "Prošla god.",
    no: "I fjor",
  },
  "wakatimecard.last7days": {
    en: "last 7 days",
    ar: "آخر 7 أيام",
    az: "Son 7 gün",
    cn: "最近 7 天",
    "zh-tw": "最近 7 天",
    cs: "Posledních 7 dní",
    de: "Letzte 7 Tage",
    bn: "গত ৭ দিন",
    es: "Últimos 7 días",
    fa: "هفت روز گذشته",
    fi: "Viimeiset 7 päivää",
    fr: "7 derniers jours",
    hi: "पिछले 7 दिन",
    hu: "Elmúlt 7 nap",
    it: "Ultimi 7 giorni",
    ja: "過去 7 日間",
    kr: "지난 7 일",
    nl: "Afgelopen 7 dagen",
    "pt-pt": "Últimos 7 dias",
    "pt-br": "Últimos 7 dias",
    np: "गत ७ दिन",

Review comment (suggestion):
Label is shortened because it goes out of bounds ([example](https://github-readme-stats.vercel.app/api?username=anuraghazra&show=reviews,discussions_started,discussions_answered,prs_merged,prs_merged_percentage&hide_rank=false&locale=sr)):
<img width="440" height="309" alt="github-readme-stats serbian" src="https://github.com/user-attachments/assets/333677c3-d85a-4d8b-a477-8ad133b32173" />

Code after:
    fi: "Viime vuosi",
    fr: "L'année dernière",
    hi: "पिछले साल",
    hu: "Tavaly",
    it: "L'anno scorso",
    ja: "昨年",
    kr: "작년",
    nl: "Vorig jaar",
    "pt-pt": "Ano passado",
    "pt-br": "Ano passado",
    np: "गत वर्ष",
    el: "Πέρυσι",
    ro: "Anul trecut",
    ru: "За прошлый год",
    "uk-ua": "За минулий рік",
    id: "Tahun lalu",
    ml: "കഴിഞ്ഞ വർഷം",
    my: "Tahun lepas",
    sk: "Minulý rok",
    tr: "Geçen yıl",
    pl: "W zeszłym roku",
    uz: "O'tgan yil",
    vi: "Năm ngoái",
    se: "Förra året",
    th: "ปีที่แล้ว",
    sr: "Прошла год.",
    "sr-latn": "Prošla god.",
    no: "I fjor",
  },
  "wakatimecard.last7days": {
    en: "last 7 days",
    ar: "آخر 7 أيام",
    az: "Son 7 gün",
    cn: "最近 7 天",
    "zh-tw": "最近 7 天",
    cs: "Posledních 7 dní",
    de: "Letzte 7 Tage",
    bn: "গত ৭ দিন",
    es: "Últimos 7 días",
    fa: "هفت روز گذشته",
    fi: "Viimeiset 7 päivää",
    fr: "7 derniers jours",
    hi: "पिछले 7 दिन",
    hu: "Elmúlt 7 nap",
    it: "Ultimi 7 giorni",
    ja: "過去 7 日間",
    kr: "지난 7 일",
    nl: "Afgelopen 7 dagen",
    "pt-pt": "Últimos 7 dias",
    "pt-br": "Últimos 7 dias",
    np: "गत ७ दिन",
Repository: apache/hadoop
File: hadoop-tools/hadoop-aliyun/src/test/java/org/apache/hadoop/fs/aliyun/oss/ITAliyunOSSSignatureV4.java (Java)

Code before:
  private Path testFile = new Path("ITAliyunOSSSignatureV4/atestr");

  @Before
  public void setUp() throws Exception {
    conf = new Configuration();
    String bucketUri = conf.get("test.fs.oss.name");
    LOG.debug("bucketUri={}", bucketUri);
    testURI = URI.create(bucketUri);
  }

  @Test
  public void testV4() throws IOException {
    conf.set(SIGNATURE_VERSION_KEY, "V4");
    conf.set(REGION_KEY, "cn-hongkong");
    AliyunOSSFileSystem fs = new AliyunOSSFileSystem();
    fs.initialize(testURI, conf);
    assumeNotNull(fs);

    createFile(fs, testFile, true, dataset(256, 0, 255));
    FileStatus status = fs.getFileStatus(testFile);
    fs.delete(testFile);
    fs.close();
  }

  @Test
  public void testDefaultSignatureVersion() throws IOException {
    AliyunOSSFileSystem fs = new AliyunOSSFileSystem();
    fs.initialize(testURI, conf);
    assumeNotNull(fs);

    Path testFile = new Path("/test/atestr");
    createFile(fs, testFile, true, dataset(256, 0, 255));
    FileStatus status = fs.getFileStatus(testFile);
    fs.delete(testFile);
    fs.close();
  }

  @Test
  public void testV4WithoutRegion() throws IOException {
    conf.set(SIGNATURE_VERSION_KEY, "V4");
    AliyunOSSFileSystem fs = new AliyunOSSFileSystem();
    try {
      fs.initialize(testURI, conf);
    } catch (IllegalArgumentException e) {
      LOG.warn("use V4 , but do not set region, get exception={}", e);
      assertEquals("se V4 , but do not set region", e.getMessage(), "SignVersion is V4 but region is empty");
    }
  }
}


Review comment (bug):
The test should check and fail when the desired exception isn't thrown.

Code after:
    conf.set(REGION_KEY, "cn-hongkong");
    AliyunOSSFileSystem fs = new AliyunOSSFileSystem();
    fs.initialize(testURI, conf);
    assumeNotNull(fs);

    createFile(fs, testFile, true, dataset(256, 0, 255));
    FileStatus status = fs.getFileStatus(testFile);
    fs.delete(testFile);
    fs.close();
  }

  @Test
  public void testDefaultSignatureVersion() throws IOException {
    AliyunOSSFileSystem fs = new AliyunOSSFileSystem();
    fs.initialize(testURI, conf);
    assumeNotNull(fs);

    Path testFile2 = new Path("/test/atestr");
    createFile(fs, testFile2, true, dataset(256, 0, 255));
    FileStatus status = fs.getFileStatus(testFile2);
    fs.delete(testFile2);
    fs.close();
  }

  @Test
  public void testV4WithoutRegion() throws IOException {
    conf.set(SIGNATURE_VERSION_KEY, "V4");
    AliyunOSSFileSystem fs = new AliyunOSSFileSystem();
    IOException expectedException = null;
    try {
      fs.initialize(testURI, conf);
    } catch (IOException e) {
      LOG.warn("use V4 , but do not set region, get exception={}", e);
      expectedException = e;
      assertEquals("use V4 , but do not set region", e.getMessage(),
              "SignVersion is V4 but region is empty");
    }
    assertNotNull(expectedException);
  }
}
Repository: apache/hadoop
File: dev-support/docker/pkg-resolver/install-protobuf.sh (Shell)

Code before:
default_version="3.25.5"
version_to_install=$default_version
if [ -n "$2" ]; then
  version_to_install="$2"
fi

if [ "$version_to_install" != "3.25.5" ]; then
  echo "WARN: Don't know how to install version $version_to_install, installing the default version $default_version instead"
  version_to_install=$default_version
fi

if [ "$version_to_install" == "3.25.5" ]; then
  # hadolint ignore=DL3003
  mkdir -p /opt/protobuf-src &&
    curl -L -s -S \
      https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.25.5.tar.gz \
      -o /opt/protobuf.tar.gz &&
    tar xzf /opt/protobuf.tar.gz --strip-components 1 -C /opt/protobuf-src &&
    mkdir -p /opt/abseil-cpp-src &&
    curl -L -s -S \
      https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.tar.gz \
      -o /opt/abseil-cpp.tar.gz &&
    tar xzf /opt/abseil-cpp.tar.gz --strip-components 1 -C protobuf-src/third_party/abseil-cpp &&
    cd /opt/protobuf-src &&
    cmake -S . -B build -Dprotobuf_BUILD_TESTS=OFF &&
    cmake --build build --parallel $(nproc) &&
    cmake --install build --prefix /opt/protobuf &&
    cd /root &&
    rm -rf /opt/protobuf-src
else
  echo "ERROR: Don't know how to install version $version_to_install"
  exit 1
fi


Review comment (suggestion):
https://github.com/protocolbuffers/protobuf/pull/10132 (since protobuf 3.22.0) removes  autotools support, the supported toolchains are bazel and cmake.

Code after:
default_version="3.25.5"
version_to_install=$default_version
if [ -n "$2" ]; then
  version_to_install="$2"
fi

if [ "$version_to_install" != "3.25.5" ]; then
  echo "WARN: Don't know how to install version $version_to_install, installing the default version $default_version instead"
  version_to_install=$default_version
fi

if [ "$version_to_install" == "3.25.5" ]; then
  # hadolint ignore=DL3003
  mkdir -p /opt/protobuf-src &&
    curl -L -s -S \
      https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.25.5.tar.gz \
      -o /opt/protobuf.tar.gz &&
    tar xzf /opt/protobuf.tar.gz --strip-components 1 -C /opt/protobuf-src &&
    curl -L -s -S \
      https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.tar.gz \
      -o /opt/abseil-cpp.tar.gz &&
    tar xzf /opt/abseil-cpp.tar.gz --strip-components 1 -C /opt/protobuf-src/third_party/abseil-cpp &&
    cd /opt/protobuf-src &&
    cmake -S . -B build -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF &&
    cmake --build build --parallel $(nproc) &&
    cmake --install build --prefix /opt/protobuf &&
    cd /root &&
    rm -rf /opt/protobuf-src
else
  echo "ERROR: Don't know how to install version $version_to_install"
  exit 1
fi
Repository: apache/hadoop
File: hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/util/bulk_crc32_riscv.c (C)

Code before:

  uintptr_t mis = (uintptr_t)p & 0xF;
  if (unlikely(mis)) {
    size_t pre = 16 - mis;
    if (pre > n) pre = n;
    crc = rv_crc32_zlib_bitwise(crc, p, pre);
    p += pre;
    n -= pre;
  }

  uint64_t x0 = *(const uint64_t *)(const void *)(p + 0);
  uint64_t x1 = *(const uint64_t *)(const void *)(p + 8);
  x0 ^= (uint64_t)crc;
  p += 16;
  n -= 16;

  const uint64_t C1 = RV_CRC32_CONST_R3;
  const uint64_t C2 = RV_CRC32_CONST_R4;

  while (likely(n >= 16)) {
    uint64_t tL = rv_clmul(C2, x1);
    uint64_t tH = rv_clmulh(C2, x1);
    uint64_t yL = rv_clmul(C1, x0);
    uint64_t yH = rv_clmulh(C1, x0);
    x0 = yL ^ tL;
    x1 = yH ^ tH;

    uint64_t d0 = *(const uint64_t *)(const void *)(p + 0);
    uint64_t d1 = *(const uint64_t *)(const void *)(p + 8);
    x0 ^= d0;
    x1 ^= d1;
    p += 16;
    n -= 16;
  }

  {
    uint64_t tH = rv_clmulh(x0, C2);
    uint64_t tL = rv_clmul(x0, C2);
    x0 = x1 ^ tL;
    x1 = tH;
  }

  uint64_t hi = x1;
  uint64_t lo = x0;
  uint64_t t2 = (lo >> 32) | (hi << 32);
  lo &= RV_CRC32_MASK32;

  lo = rv_clmul(RV_CRC32_CONST_R5, lo) ^ t2;
  uint64_t tmp = lo;
  lo &= RV_CRC32_MASK32;
  lo = rv_clmul(lo, RV_CRC32_CONST_RU);

Review comment (suggestion):
comment that this is to handle misaligned data and that this is considered unlikely

Code after:
  for (size_t i = 0; i < len; ++i) {
    c ^= buf[i];
    for (int k = 0; k < 8; ++k) {
      uint32_t mask = -(int32_t)(c & 1);
      c = (c >> 1) ^ (0xEDB88320U & mask);  // reflected polynomial
    }
  }
  return c;
}

/**
 * Hardware-accelerated CRC32 (zlib) calculation using RISC-V Zbc
 * carry-less multiplication instructions.
 */
static uint32_t rv_crc32_zlib_clmul(uint32_t crc, const uint8_t *buf,
                                    size_t len) {
  const uint8_t *p = buf;
  size_t n = len;

  if (n < 32) {
    return rv_crc32_zlib_bitwise(crc, p, n);
  }

  // Handle misaligned data at the start. This is considered unlikely
  // in typical Hadoop usage but necessary for correctness.
  uintptr_t mis = (uintptr_t)p & 0xF;
  if (unlikely(mis)) {
    size_t pre = 16 - mis;
    if (pre > n) pre = n;
    crc = rv_crc32_zlib_bitwise(crc, p, pre);
    p += pre;
    n -= pre;
  }

  uint64_t x0 = *(const uint64_t *)(const void *)(p + 0);
  uint64_t x1 = *(const uint64_t *)(const void *)(p + 8);
  x0 ^= (uint64_t)crc;
  p += 16;
  n -= 16;

  const uint64_t C1 = RV_CRC32_CONST_R3;
  const uint64_t C2 = RV_CRC32_CONST_R4;

  // Main loop: process 16 bytes of aligned data per iteration using
  // carry-less multiplication for high-performance folding.
  while (likely(n >= 16)) {
    uint64_t tL = rv_clmul(C2, x1);
    uint64_t tH = rv_clmulh(C2, x1);
    uint64_t yL = rv_clmul(C1, x0);
    uint64_t yH = rv_clmulh(C1, x0);
    x0 = yL ^ tL;