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
Clang warnings #194
Closed
Closed
Clang warnings #194
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The original regexp took 'unsigned short *' and captured only the 'short'. This changed allows it to capture 'unsigned short'.
Since fitgauss1d[r] has GenericTypes=>[D], it is safe to assume that everything will be Double, so using fabs is preferred.
The switch statement was written long before those datatypes were in PDL, and the compiler was nicely complaining about their absense.
Perl's 'warn' function had been undef'd because of problems with the gsl code's 'warn' variable. But PDL::PP inserts code into XS files that calls Perl's 'warn' function. To avoid this I removed the #undef warn and changed the gsl variable name from warn to gslwarn.
Some function prototypes that get generated into SlatecProtos.h have return types float or double, but most were just missing, and the compiler assumed them to be int. The function defs all do return int, so I just made it explicit.
A few functions (SDstart ... SDend) did not have function prototypes in hdf.h, this other header file was necessary.
If a user mistakenly passed a perl scalar argument to qsort and its ilk, the SV would be mistaken for a piddle and passed to the underlying generic_qsort etc routines. Not surprisingly, those routine's array index tricks would cause a segfault. This commit causes qsort, qsorti, qsortvec, and qsortveci to barf if an argument is passed with incorrect dimensions. Some care is taken to allow trivial sorts. 2 tests for each routine have been added, and some existing tests labeled.
Hopefully this will compile on Strawberry. Not sure why the original worked OK on my Mac w/ clang.
The changes in <#188> broke the build for all cases of `BADVAL_USENAN` xor `BADVAL_PER_PDL`. This was because the checking for badvalues when copying in `pdl_kludge_copy_*` did not take into account these variations in accessing and setting the badvalue. For example, a simple comparison using `==` is not valid when NaN values are being compared. Here we need to use `!finite(...)` to make the comparison if the type can use NaN values.
The example in the docs was using the matrix v directly instead of the transpose. Doesn't matter for 2x2 matrices, but does for larger. Hopefully this clears things up. I also added some tests for svd: square matrices, and rectangular matrices where m>n and m<n.
Some comments taken from Nash (1990), some are my own to aid in understanding this algorithm.
The code to determine whether the output size agreed with the format string size was only activated when the format string was input as the first argument, not in the options hash. This change activates it for both cases. Added some tests as well.
The list is generated by Types.pm.PL, but gets put into pdl.h and pdlsimple.h. This was motivated by code in Bad.c that assigns to a variable of type pdl_datatypes the value -1 (in some error condition that is unlikely to be reached). This jives with the ANYVAL_FROM_CTYPE macro in pdl.h. Thanks to Chris Marshall and David Mertens for the pointers. See pdl-devel 2016-05-05 discussion.
This was motivated because we should have been using labs or llabs, the correct function to call was system-dependent. This avoides all that by replacing the abs() call with multiplication by the variable's sign.
fabs is fine for doubles, but not for anything else: this inserts the correct function (abs, labs, llabs, etc) based on the datatype used in the complex division. I hope.
This silences a compiler warning about a printf wanting double ("%f") but we passed an Anyval.
Most prototypes get inserted into SlatecProtos.h by defslatec. But polfit_ and dpolft_ do not, so they need to be added manually.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The branch add_datatype_invalid branched off of the branch clang_warnings, so before I fully merge the former in I want to make sure everything on this one checks out ok.