Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

[linux-port] Fix a handful of warnings in headers - #192

Merged
ehsannas merged 1 commit into
google:linuxfrom
pow2clk:pow2clk-fixup
May 18, 2018
Merged

ehsannas merged 1 commit into
google:linuxfrom
pow2clk:pow2clk-fixup

Conversation

@pow2clk

@pow2clk pow2clk commented May 18, 2018

Copy link
Copy Markdown

Just a few warning conditions in a handful of common headers
was producing pages and pages of warning messages. By fixing them,
the output spew is reduced significantly.

Static variables in a header produce a separate variable for every
file that includes it. In many of these, these variables were unused.
Instead, variables used in multiple files should be defined only
once in a source file and declared as extern in the header.

The implementation of DXASSERT for non-MS platforms in Global.h
included a character array as part of the assert conditional
which is always true, producing a warning. Furthermore, I don't
think this would do what was expected as it would present no
string. Instead, the message is printed out and an assert is raised.

Many unsigned variables were checked to be greater than zero and less
than 3 in HlslTypes.h. If they were somehow assigned a negative
value, it would appear as much greater than 3 in unsigned form.
So we can just check that they are less than or equal to 3.

In Type.h, parammods_begin() was casting its return value to the
proper pointer, but without const, producing an error. The best
part is that the function returned a const pointer. The cast was
just wrong. Adding const silences the warning.

Facilitates #184

Just a few warning conditions in a handful of common headers
was producing pages and pages of warning messages. By fixing them,
the output spew is reduced significantly.

Static variables in a header produce a separate variable for every
file that includes it. In many of these, these variables were unused.
Instead, variables used in multiple files should be defined only
once in a source file and declared as extern in the header.

The implementation of DXASSERT for non-MS platforms in Global.h
included a character array as part of the assert conditional
which is always true, producing a warning. Furthermore, I don't
think this would do what was expected as it would present no
string. Instead, the message is printed out and an assert is raised.

Many unsigned variables were checked to be greater than zero and less
than 3 in HlslTypes.h. If they were somehow assigned a negative
value, it would appear as much greater than 3 in unsigned form.
So we can just check that they are less than or equal to 3.

In Type.h, parammods_begin() was casting its return value to the
proper pointer, but without const, producing an error. The best
part is that the function returned a const pointer. The cast was
just wrong. Adding const silences the warning.

Facilitates google#184
@ehsannas
ehsannas requested a review from antiagainst May 18, 2018 15:46
@ehsannas
ehsannas self-requested a review May 18, 2018 15:46

@ehsannas ehsannas left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

static const char* kFP32DenormKindString = "fp32-denorm-mode";
static const char* kFP32DenormValueAnyString = "any";
static const char* kFP32DenormValuePreserveString = "preserve";
static const char* kFP32DenormValueFtzString = "ftz";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to see the removal of static pointer from header file.

#define DXASSERT_LOCALVAR(local, exp, msg) DXASSERT(exp, msg)
#define DXVERIFY_NOMSG assert
#define DXASSERT(expr, fmt, ...) do { if (!(expr)) { char msg[80]; sprintf(msg, fmt, ##__VA_ARGS__); assert(false && msg); } } while (0);
#define DXASSERT(expr, fmt, ...) do { if (!(expr)) { fprintf(stderr, fmt, ##__VA_ARGS__); assert(false); } } while (0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. I had run into this before and forgot to fix it. Before your fix, the assertion failure would print on screen as:
assertion failed: false && msg
:)

@pow2clk

pow2clk commented May 18, 2018

Copy link
Copy Markdown
Author

build timed out. They seem to do that now and then. I don't think it has to do with the change.

@AppVeyorBot

Copy link
Copy Markdown

@ehsannas
ehsannas removed the request for review from antiagainst May 18, 2018 17:04
@ehsannas
ehsannas merged commit db5d3ef into google:linux May 18, 2018
@antiagainst

Copy link
Copy Markdown

Awesome stuff!

@ehsannas ehsannas mentioned this pull request May 18, 2018
35 of 38 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants