You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by "Leif Hedstrom (JIRA)" <ji...@apache.org> on 2009/11/02 05:22:59 UTC

[jira] Commented: (TS-5) Compiler warnings on unused return values

    [ https://issues.apache.org/jira/browse/TS-5?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12772413#action_12772413 ] 

Leif Hedstrom commented on TS-5:
--------------------------------

What's strange is that these types of warnings / errors only fail on Ubuntu. The same compilers on Fedora does not seem to complain at all. Odd.

> Compiler warnings on unused return values
> -----------------------------------------
>
>                 Key: TS-5
>                 URL: https://issues.apache.org/jira/browse/TS-5
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: Build
>    Affects Versions: 2.0a
>            Reporter: Leif Hedstrom
>            Priority: Minor
>
> GCC 4.3.3 is rather *insistent* when you ignore results declared with warn_unused_result. Cast-to-void doesn't do any good (google it). About 150 of those.
> fgets() is the primary culprit (~100), then system(), then a smattering of random calls (pipe(), write(), ...). It's ugly, you end up needing the old "dummy" in some cases, e.g. for something like ink_stack_trace_dump() (what, write the problem about stderr onto some other FD? ;-) ) Of course some others are genuine.
> Turn it off? Slog through it?
> --- libinktomi++/ink_stack_trace.cc     (revision 831451)
> +++ libinktomi++/ink_stack_trace.cc     (working copy)
> @@ -76,13 +76,14 @@
>  ink_stack_trace_dump(int sighandler_frame)
>  {
>    int btl;
> +  int dummy;
>  
>    // Recopy and re-terminate the app name in case it has been trashed.
>    char name[256];
>    char *msg = " - STACK TRACE: \n";
>    ink_strncpy(name, program_name, sizeof(name) - 2);
> -  write(2, name, strlen(name));
> -  write(2, msg, strlen(msg));
> +  dummy = write(2, name, strlen(name));
> +  dummy = write(2, msg, strlen(msg));
>  
>    void *stack[INK_STACK_TRACE_MAX_LEVELS + 1];
>    memset(stack, 0, sizeof(stack));
> Grepping through a make -k:
> TimeConfig.cc:75: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> TimeConfig.cc:100: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> TimeConfig.cc:142: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> TimeConfig.cc:150: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> TimeConfig.cc:160: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> TimeConfig.cc:165: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> TimeConfig.cc:187: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> TimeConfig.cc:194: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> TimeConfig.cc:202: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> TimeConfig.cc:212: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> TimeConfig.cc:225: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> TimeConfig.cc:227: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> TimeConfig.cc:245: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> TimeConfig.cc:250: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> TimeConfig.cc:258: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> TimeConfig.cc:260: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> TimeConfig.cc:261: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> TimeConfig.cc:266: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> TimeConfig.cc:267: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> WebMgmtUtils.cc:1582: error: ignoring return value of 'int pipe(int*)', declared with attribute warn_unused_result
> WebMgmtUtils.cc:1584: error: ignoring return value of 'int pipe(int*)', declared with attribute warn_unused_result
> WebMgmtUtils.cc:1640: error: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result
> WebHttp.cc:2962: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> WebHttp.cc:4799: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> WebHttpRender.cc:3716: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> ../INKMgmtAPI.cc:2974: error: ignoring return value of 'int pipe(int*)', declared with attribute warn_unused_result
> ../INKMgmtAPI.cc:3028: error: ignoring return value of 'int pipe(int*)', declared with attribute warn_unused_result
> ../INKMgmtAPI.cc:3146: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ../INKMgmtAPI.cc:3244: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ../INKMgmtAPI.cc:3264: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ../INKMgmtAPI.cc:3340: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ../INKMgmtAPI.cc:3361: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ../INKMgmtAPI.cc:3427: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ../INKMgmtAPI.cc:3478: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ../INKMgmtAPI.cc:3568: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> CoreAPIRemote.cc:221: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> CoreAPIRemote.cc:255: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> APITestCliRemote.cc:2731: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> INKMgmtAPI.cc:2974: error: ignoring return value of 'int pipe(int*)', declared with attribute warn_unused_result
> INKMgmtAPI.cc:3028: error: ignoring return value of 'int pipe(int*)', declared with attribute warn_unused_result
> INKMgmtAPI.cc:3146: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> INKMgmtAPI.cc:3244: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> INKMgmtAPI.cc:3264: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> INKMgmtAPI.cc:3340: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> INKMgmtAPI.cc:3361: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> INKMgmtAPI.cc:3427: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> INKMgmtAPI.cc:3478: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> INKMgmtAPI.cc:3568: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> CliMgmtUtils.cc:598: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> CliMgmtUtils.cc:618: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3685: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3770: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3799: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3810: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3815: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3818: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3830: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3867: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3876: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3880: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3883: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3909: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3920: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3925: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3928: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:3940: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:5114: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:5146: error: ignoring return value of 'int getdomainname(char*, size_t)', declared with attribute warn_unused_result
> ConfigCmd.cc:5184: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:5241: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:6326: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> ConfigCmd.cc:6350: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> UtilCmds.cc:184: error: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
> Main.cc:309: error: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result
> Main.cc:1470: error: ignoring return value of 'int chdir(const char*)', declared with attribute warn_unused_result
> signals.cc:311: error: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result
> signals.cc:311: error: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result
> logstats.cc:2022: error: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result
> --
> Stephane Belmon <sb...@websense.com>
> Principal Software Engineer
> Websense, inc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.