Closed Bug 1345357 Opened 3 years ago Closed 3 years ago

nsFeedSniffer.cpp: error: ignoring return value of function declared with attribute warn_unused_result

Categories

(SeaMonkey :: Build Config, defect)

defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED
seamonkey2.52

People

(Reporter: ewong, Assigned: ewong)

Details

Attachments

(1 file, 1 obsolete file)

current trunk bustage:

/usr/bin/ccache /builds/slave/c-cen-t-lnx/build/gcc/bin/g++ -m32 -march=pentium-m -std=gnu++11 -o nsFeedSniffer.o -c -I/builds/slave/c-cen-t-lnx/build/objdir/dist/stl_wrappers -I/builds/slave/c-cen-t-lnx/build/objdir/dist/system_wrappers -include /builds/slave/c-cen-t-lnx/build/mozilla/config/gcc_hidden.h -DNDEBUG=1 -DTRIMMED=1 -DSTATIC_EXPORTABLE_JS_API -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -I/builds/slave/c-cen-t-lnx/build/suite/feeds/src -I/builds/slave/c-cen-t-lnx/build/objdir/suite/feeds/src  -I/builds/slave/c-cen-t-lnx/build/objdir/dist/include  -I/builds/slave/c-cen-t-lnx/build/objdir/dist/include/nspr -I/builds/slave/c-cen-t-lnx/build/objdir/dist/include/nss       -fPIC  -DMOZILLA_CLIENT -include /builds/slave/c-cen-t-lnx/build/objdir/mozilla-config.h -MD -MP -MF .deps/nsFeedSniffer.o.pp  -Wall -Wc++11-compat -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wwrite-strings -Wno-invalid-offsetof -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wformat -msse -msse2 -mfpmath=sse -fno-exceptions -fno-strict-aliasing -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -D_GLIBCXX_USE_CXX11_ABI=0 -pipe  -g -freorder-blocks -Os -fno-omit-frame-pointer  -Werror   /builds/slave/c-cen-t-lnx/build/suite/feeds/src/nsFeedSniffer.cpp
/builds/slave/c-cen-t-lnx/build/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.4/../../../../x86_64-unknown-linux-gnu/bin/as: /lib64/libz.so.1: no version information available (required by /builds/slave/c-cen-t-lnx/build/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.4/../../../../x86_64-unknown-linux-gnu/bin/as)
../../../../suite/feeds/src/nsFeedSniffer.cpp: In member function 'nsresult nsFeedSniffer::ConvertEncodedData(nsIRequest*, const uint8_t*, uint32_t)':
../../../../suite/feeds/src/nsFeedSniffer.cpp:58:50: error: ignoring return value of function declared with attribute warn_unused_result [-Werror=unused-result]
                                  contentEncoding);
                                                  ^
../../../../suite/feeds/src/nsFeedSniffer.cpp: In member function 'virtual nsresult nsFeedSniffer::GetMIMETypeFromContent(nsIRequest*, const uint8_t*, uint32_t, nsACString_internal&)':
../../../../suite/feeds/src/nsFeedSniffer.cpp:209:36: error: ignoring return value of function declared with attribute warn_unused_result [-Werror=unused-result]
   channel->GetRequestMethod(method);
                                    ^
../../../../suite/feeds/src/nsFeedSniffer.cpp:262:102: error: ignoring return value of function declared with attribute warn_unused_result [-Werror=unused-result]
                                NS_LITERAL_CSTRING("1"), false);
                                                                                                      ^
cc1plus: all warnings being treated as errors
make[4]: *** [nsFeedSniffer.o] Error 1
make[4]: Leaving directory `/builds/slave/c-cen-t-lnx/build/objdir/suite/feeds/src'
make[3]: *** [suite/feeds/src/target] Error 2
Version: SeaMonkey 2.48 Branch → unspecified
Summary: nsFeedSniffer.cpp: error: error: ignoring return value of function declared with attribute warn_unused_result → nsFeedSniffer.cpp: error: ignoring return value of function declared with attribute warn_unused_result
Attached patch proposed patch (v1) (obsolete) — Splinter Review
Attachment #8844775 - Flags: review?(iann_bugzilla)
Assignee: nobody → ewong
Status: NEW → ASSIGNED
Comment on attachment 8844775 [details] [diff] [review]
proposed patch (v1)


>+++ b/suite/feeds/src/nsFeedSniffer.cpp
>@@ -49,17 +49,18 @@ nsFeedSniffer::ConvertEncodedData(nsIReq
>   nsresult rv = NS_OK;
> 
>  mDecodedData = "";
>  nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request));
>   if (!httpChannel)
>     return NS_ERROR_NO_INTERFACE;
> 
>   nsAutoCString contentEncoding;
>-  httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Encoding"),
>+  nsresult rv;
Isn't rv already defined, should we be using another variable?

>+  rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Encoding"),
>                                  contentEncoding);
Nit: indent this line correctly too.


>@@ -201,17 +202,18 @@ nsFeedSniffer::GetMIMETypeFromContent(ns
>                                       nsACString& sniffedType)
> {
>   nsCOMPtr<nsIHttpChannel> channel(do_QueryInterface(request));
>   if (!channel)
>     return NS_ERROR_NO_INTERFACE;
> 
>   // Check that this is a GET request, since you can't subscribe to a POST...
>   nsAutoCString method;
>-  channel->GetRequestMethod(method);
>+  nsresult rv;
>+  rv = channel->GetRequestMethod(method);
rv is defined later in this method, so that will need removing?


>@@ -253,18 +255,19 @@ nsFeedSniffer::GetMIMETypeFromContent(ns
>     // check for an attachment after we have a likely feed.
>     if(HasAttachmentDisposition(channel)) {
>       sniffedType.Truncate();
>       return NS_OK;
>     }
> 
>     // set the feed header as a response header, since we have good metadata
>     // telling us that the feed is supposed to be RSS or Atom
>-    channel->SetResponseHeader(NS_LITERAL_CSTRING("X-Moz-Is-Feed"),
>-                               NS_LITERAL_CSTRING("1"), false);
>+    nsresult rv;
>+    rv = channel->SetResponseHeader(NS_LITERAL_CSTRING("X-Moz-Is-Feed"),
>+                                    NS_LITERAL_CSTRING("1"), false);
You have already defined rv earlier in the method...

r=me with those addressed.
Attachment #8844775 - Flags: review?(iann_bugzilla) → review+
(In reply to Ian Neal from comment #2)
> Comment on attachment 8844775 [details] [diff] [review]
> proposed patch (v1)
> 
> 
> >+++ b/suite/feeds/src/nsFeedSniffer.cpp
> >@@ -49,17 +49,18 @@ nsFeedSniffer::ConvertEncodedData(nsIReq
> >   nsresult rv = NS_OK;
> > 
> >  mDecodedData = "";
> >  nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request));
> >   if (!httpChannel)
> >     return NS_ERROR_NO_INTERFACE;
> > 
> >   nsAutoCString contentEncoding;
> >-  httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Encoding"),
> >+  nsresult rv;
> Isn't rv already defined, should we be using another variable?

Having looked at the code, I'm sure we can use rv, since it's used
later on in line 66.

Does it make sense to do this:

  rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Encoding"),
                                      contentEncoding);
  NS_ENSURE_SUCCESS(rv, rv);
Also, do we need something like (@ line 211):

  nsresult rv;
  rv = channel->GetRequestMethod(method);
Attachment #8844775 - Attachment is obsolete: true
Attachment #8845267 - Flags: review?(iann_bugzilla)
Attachment #8845267 - Flags: review?(iann_bugzilla) → review+
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → seamonkey2.52
You need to log in before you can comment on or make changes to this bug.