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

Add basic error handling #881

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion profiler/src/ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ ini_t* ini_load(const char *filename) {

/* Get file size */
fseek(fp, 0, SEEK_END);
sz = ftell(fp);
const long file_size = ftell(fp);
sz = file_size > 0 ? file_size : 0;
rewind(fp);

/* Load file content into memory, null terminate, init end var */
Expand Down
6 changes: 4 additions & 2 deletions server/TracyPrint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ static inline char* PrintFloat( char* begin, char* end, T value, int precision )
#ifndef NO_CHARCONV
return std::to_chars( begin, end, value, std::chars_format::fixed, precision ).ptr;
#else
return begin + sprintf( begin, "%.*f", precision, value );
auto length = sprintf( begin, "%.*f", precision, value );
return length < 0 ? "" : begin + length; // TODO: Proper error handling for negative length
#endif
}

Expand All @@ -95,7 +96,8 @@ static inline char* PrintFloat( char* begin, char* end, T value )
#ifndef NO_CHARCONV
return std::to_chars( begin, end, value, std::chars_format::fixed ).ptr;
#else
return begin + sprintf( begin, "%f", value );
auto length = sprintf( begin, "%f", value );
return length < 0 ? "" : begin + length; // TODO: Proper error handling for negative length
#endif
}

Expand Down