- Notifications
You must be signed in to change notification settings - Fork15
Fix warnings in output.c#51
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -21,7 +21,11 @@ | ||
* Default is radians. | ||
*/ | ||
static unsigned char sphere_output = OUTPUT_RAD; | ||
/* | ||
* Defines the precision of floating point values in output. | ||
*/ | ||
static int sphere_output_precision = DBL_DIG; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I still don’t understand how changing this from short int to int fixes the compiler error:
but I do 100% agree that the argument to sprintf should be int. I’m going to just chalk this up to this gcc version not being quite right. ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. @esabol sprintf takes variadic arguments that is implemented using va_list in C language. sprintf decides how to format the memory chunk with arguments based on the template. I guess, it is like to read raw bytes from a stream and try to interpret them. There is an undefined behaviour if sprintf expects int type (4 bytes), but short int (2 bytes) is passed instead. It seems 2 extra bytes belong to the next argument, depending on the implementation of va_list. It is a real bug that can lead to some unexpected program behaviour and it should be fixed. The problem with some magic numbers in temporary buffers is not so important. The case with buffer overflow is unlikely in this case. If we want to redesign this behaviour it should be rewritten completely. Some checks for buffer overflows should be implemented. P.S.
| ||
PG_FUNCTION_INFO_V1(set_sphere_output); | ||
PG_FUNCTION_INFO_V1(spherepoint_out); | ||