Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code from custom bool_t to stdbool.h (where available) #1176

Open
jimklimov opened this issue Nov 11, 2021 · 0 comments
Open

Refactor code from custom bool_t to stdbool.h (where available) #1176

jimklimov opened this issue Nov 11, 2021 · 0 comments
Labels
C-bool Issues and PRs about C/C++ methods, headers and data types dealing with boolean types refactor/fightwarn PR or issue proposal to improve code maintainability without functional changes, or to fix warnings
Milestone

Comments

@jimklimov
Copy link
Member

jimklimov commented Nov 11, 2021

Currently many places in codebase copy around a definition of a bool_t as enum or int; there are few uses of stdbool.h that should have handled the type.

I suppose we have legacy systems to consider that might not have this header yet, so maybe a nut_stdbool.h (similar in purpose and construct to timehead.h and nut_stdint.h) is in order, to streamline this basic type definition and use.

UPDATE: See also, some prior art found:

@jimklimov jimklimov added the refactor/fightwarn PR or issue proposal to improve code maintainability without functional changes, or to fix warnings label Nov 14, 2021
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 20, 2021
…n of bool_t"

This reverts commit ffc7bce.

In some build scenarios it ends up not defined.

Defer solution to upstream NUT issue networkupstools#1176
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 20, 2021
…n of bool_t"

This reverts commit ffc7bce.

In some build scenarios it ends up not defined.

Defer solution to upstream NUT issue networkupstools#1176
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 20, 2021
…n of bool_t"

This reverts commit ffc7bce.

In some build scenarios it ends up not defined.

Defer solution to upstream NUT issue networkupstools#1176
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 20, 2021
…n of bool_t"

This reverts commit ffc7bce.

In some build scenarios it ends up not defined.

Defer solution to upstream NUT issue networkupstools#1176
jimklimov added a commit to jimklimov/nut that referenced this issue Jan 17, 2022
…n of bool_t"

This reverts commit ffc7bce.

In some build scenarios it ends up not defined.

Defer solution to upstream NUT issue networkupstools#1176
@jimklimov jimklimov added this to the 2.8.1 milestone Apr 26, 2022
@jimklimov jimklimov modified the milestones: 2.8.1, 2.8.2 Jan 6, 2023
@jimklimov jimklimov modified the milestones: 2.8.2, 2.8.3 Apr 4, 2024
@jimklimov jimklimov added the C-bool Issues and PRs about C/C++ methods, headers and data types dealing with boolean types label Apr 10, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 16, 2024
….h> and/or <float.h> [networkupstools#1176]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 16, 2024
…test.c et al: introduce a NUT_CHECK_BOOL scriptlet and a header with nut_bool_t type [networkupstools#1176]

Chose to use a unique type name to avoid conflicts with third-party headers
which deliver a `bool_t` (currently commonly hacked into many NUT sources).

Using lower-cased `true` and `false` values, hoping for maximum compatibility
with C99 and newer language standards (if the compilers do implement them on
whatever obscure platform NUT gets built on, and then our new `nut_bool_t`
definition can be just an alias for what the language gives us).

A test case was added to make sure it behaves as expected on different systems.

Converting the sources from their custom type definitions and usages would
be a separate step.

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 19, 2024
…lean type/value usage [networkupstools#1176]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 19, 2024
…ent [networkupstools#1176]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@jimklimov jimklimov modified the milestones: 2.8.3, 2.8.4 Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bool Issues and PRs about C/C++ methods, headers and data types dealing with boolean types refactor/fightwarn PR or issue proposal to improve code maintainability without functional changes, or to fix warnings
Projects
None yet
Development

No branches or pull requests

1 participant