Skip to content

Clang [-Wshorten-64-to-32] warnings in htop code #1673

Open
@Explorer09

Description

@Explorer09

This spreadsheet contains all [-Wshorten-64-to-32] warnings that I can find within htop codebase:

https://docs.google.com/spreadsheets/d/12P6VnjGBcqXA-vDI-lsBHiAsmJoruPdLBPfZ3TKNCbg/edit?usp=sharing

I didn't test all of the platforms supported in htop, but I have tried my best.

Platforms tested: Linux, FreeBSD, OpenBSD, macOS (Darwin), PCP and Unsupported
Platforms not tested: NetBSD, DragonFly BSD and Solaris

There are 151 134 107 [-Wshorten-64-to-32] warnings in total in the attached spreadsheet.

This page marks all lines with the warnings.

I have also tried categorizing the warnings on the real problems behind or how to fix them. The pull requests #1588 (merged), #1668 (merged) and #1669 (merged) are parts of the solutions to these warnings.

Keywords in the Notes column:

"Cmdline"

(The PR 1588 has been merged.)

Related to byte offsets and lengths of processes' "cmdline", "comm" and "exe" path strings. The ideal solution is to promote the type of these from int to size_t. I have proposed #1588 for this.

"Terminal-width"

These variables or data have confusing uses of string length (strlen and friends) and the display width of the string (number of terminal columns the string can occupy, a la wcswidth). I cannot totally fix the problems in this category for now, as the reworking of certain functions to refer to widths instead can be difficult. I'm not sure if a quick workaround to silence the warning could be accepted. (The workaround I had in mind is using (int)strnlen(str, INT_MAX).)

"strto*"

These are about conversion of atol, strtol, strtoul, strtoull etc. results to smaller integer types. There should be bound checks (or, for fast-strto* functions, assertions on the limits).

"Hashtable-key"

Related to bit widths allowed for Hashtable keys.

"PCP-Metric"

Related to the Metric data type in the PCP code. I won't fix this one as I have little knowledge with the PCP code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions