fix(taos-tools): fix sast warnings - #34719
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes SAST (Static Application Security Testing) warnings across the tools/taos-tools and tools/shell components. The changes are primarily mechanical, suppressing ignored return values and fixing type-related issues.
Changes:
- Cast return values of functions like
snprintf,sprintf,localtime_r,localtime_s,atomic_add_fetch_64,pthread_mutex_*,sem_post,closedir,benchArrayPush,argp_parse, etc. to(void)to suppress unused-return-value SAST warnings. - Fix type mismatches: loop variables changed from
intto appropriate unsigned/sized types (uint32_t,uint8_t,size_t, etc.); comparisons involving signed/unsigned types corrected; integer conversions made explicit with casts. - Minor code cleanups: trailing whitespace removed,
0replaced withNULLfor pointer comparisons,(double)cast corrected to(int64_t)for timestamp,char* data = 0corrected tochar* data = NULL, null-check added formallocinsetRenameDbsandreplaceNewName, variable change frominttouint32_tinfast_sqrt.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
tools/taos-tools/test/taosdumpTest.cpp |
Cast setConsoleEcho return values to (void) |
tools/taos-tools/src/toolstime.c |
Cast time function return values to (void) |
tools/taos-tools/src/taosdump.c |
Cast snprintf, atomic_add_fetch_64, closedir returns to (void); add NULL checks |
tools/taos-tools/src/dumpUtil.c |
Cast mutex and sprintf return values to (void); fix loop variable type; fix pointer comparison |
tools/taos-tools/src/benchUtilDs.c |
Change i from int to uint32_t in fast_sqrt; cast ds_grow/ds_add_str returns to (void) |
tools/taos-tools/src/benchUtil.c |
Fix various type issues and cast unused returns to (void) |
tools/taos-tools/src/benchTmq.c |
Cast snprintf returns to (void); whitespace cleanup |
tools/taos-tools/src/benchSys.c |
Cast argp_parse/benchArrayPush returns to (void); whitespace cleanup |
tools/taos-tools/src/benchQuery.c |
Fix signed/unsigned comparison; correct format specifier |
tools/taos-tools/src/benchMain.c |
Cast snprintf/sem_post returns to (void); whitespace cleanup |
tools/taos-tools/src/benchLog.c |
Cast mutex returns to (void) |
tools/taos-tools/src/benchJsonOpt.c |
Fix type casts; remove dead scale < 0 check; cast array push returns |
tools/taos-tools/src/benchInsertMix.c |
Fix macro comparison; cast sprintf returns to (void); whitespace |
tools/taos-tools/src/benchInsert.c |
Fix signed/unsigned comparison; cast snprintf/sprintf returns to (void) |
tools/taos-tools/src/benchDataMix.c |
Cast sprintf returns to (void); whitespace cleanup |
tools/taos-tools/src/benchDataGeometry.c |
Cast benchArrayPush/benchArrayDestroy/geoObject2DToStr returns to (void) |
tools/taos-tools/src/benchData.c |
Fix type casts; change loop variable types; cast snprintf returns to (void) |
tools/taos-tools/src/benchCsv.c |
Fix loop variable types from uint32_t to size_t; cast time function returns |
tools/taos-tools/src/benchCommandOpt.c |
Cast benchArrayPush/snprintf returns to (void) |
tools/taos-tools/inc/benchLog.h |
Cast toolsGetTimeOfDay returns to (void) in log macros |
tools/shell/src/shellArguments.c |
Cast sprintf returns to (void) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on improving the code quality and addressing static analysis security testing (SAST) warnings within the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request aims to fix static analysis warnings, primarily by casting return values of various functions to (void). While this suppresses warnings, it sometimes hides potential bugs or security vulnerabilities. I've identified several critical issues where ignoring return values could lead to crashes, deadlocks, or incorrect behavior. Specifically, error handling for mutex operations and time functions should be added. I've also pointed out unsafe sprintf calls that should be replaced with snprintf to prevent buffer overflows. On the positive side, many changes correctly fix type mismatches and remove trailing whitespace, improving code quality.
Note: Security Review did not run due to the size of the PR.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zitsen
left a comment
There was a problem hiding this comment.
Code review complete. Changes look good - this PR properly addresses SAST warnings by:
- Casting unused return values to
(void)(standard practice) - Fixing type mismatches (int to uint32_t/size_t where appropriate)
- Converting sprintf to snprintf with buffer sizes in shellArguments.c
- Minor code cleanups (trailing whitespace, NULL comparisons)
No critical issues found. Safe to merge.

Description
Fix sast warnings.
Issue(s)
Checklist
Please check the items in the checklist if applicable.