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

Fix warning about ignoring return value of asprintf #48

Open
alistairking opened this issue Jun 27, 2018 · 2 comments
Open

Fix warning about ignoring return value of asprintf #48

alistairking opened this issue Jun 27, 2018 · 2 comments

Comments

@alistairking
Copy link
Member

(Ideally also replacing use of asprintf with snprintf)

tsk-proxy.c: In function ‘inc_stat’:
tsk-proxy.c:208:3: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
   asprintf(&stats_key, "%s.%s", stats_key_prefix, stats_key_suffix);
   ^
tsk-proxy.c: In function ‘init_kafka’:
tsk-proxy.c:380:3: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
   asprintf(&topic_name, "%s.%s", cfg->kafka_topic_prefix, cfg->kafka_channel);
   ^
tsk-proxy.c:381:3: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
   asprintf(&group_id, "%s.%s", cfg->kafka_consumer_group, topic_name);
   ^
tsk-proxy.c: In function ‘create_stats_prefix’:
tsk-proxy.c:580:3: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
   asprintf(&stats_key_prefix, "%s.%s.%s.%s", STATS_METRIC_PREFIX,
   ^
@NullHypothesis
Copy link
Contributor

It's easy to make sure that the return code isn't -1 but why use snprintf instead? For portability reasons?

@alistairking
Copy link
Member Author

Yeah

NullHypothesis added a commit that referenced this issue Jul 20, 2018
asprintf() is a GNU/BSD extension and not part of C or POSIX.  To avoid
portability issues, we should use our own implementation of asprintf().

This fixes <#48>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants