On 04/08/2010 03:33 PM, Nikola Pajkovsky wrote:
> From bfbffc2fcf9c77d29802a2773b5a89436b1d5d86 Mon Sep 17 00:00:00
2001
From: Nikola Pajkovsky<npajkovs(a)redhat.com>
Date: Thu, 8 Apr 2010 15:32:19 +0200
Subject: [PATCH] kerneloop is more informative when failed
Signed-off-by: Nikola Pajkovsky<npajkovs(a)redhat.com>
---
lib/Plugins/KerneloopsReporter.cpp | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/lib/Plugins/KerneloopsReporter.cpp
b/lib/Plugins/KerneloopsReporter.cpp
index 5be0c8d..53db3cd 100644
--- a/lib/Plugins/KerneloopsReporter.cpp
+++ b/lib/Plugins/KerneloopsReporter.cpp
@@ -48,7 +48,7 @@ static size_t writefunction(void *ptr, size_t size,
size_t nmemb, void *stream)
/* Send oops data to kerneloops.org-style site, using HTTP POST */
/* Returns 0 on success */
-static int http_post_to_kerneloops_site(const char *url, const char
*oopsdata)
+static CURLcode http_post_to_kerneloops_site(const char *url, const
char *oopsdata)
{
CURLcode ret;
CURL *handle;
@@ -67,6 +67,7 @@ static int http_post_to_kerneloops_site(const char
*url, const char *oopsdata)
CURLFORM_COPYCONTENTS, "yes",
CURLFORM_END);
+
curl_easy_setopt(handle, CURLOPT_HTTPPOST, post);
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writefunction);
@@ -75,7 +76,7 @@ static int http_post_to_kerneloops_site(const char
*url, const char *oopsdata)
curl_formfree(post);
curl_easy_cleanup(handle);
- return ret != 0;
+ return ret;
}
@@ -88,7 +89,7 @@ std::string CKerneloopsReporter::Report(const
map_crash_data_t& pCrashData,
const map_plugin_settings_t&
pSettings,
const char *pArgs)
{
- int ret = -1;
+ CURLcode ret;
update_client(_("Creating and submitting a report..."));
@@ -100,9 +101,10 @@ std::string CKerneloopsReporter::Report(const
map_crash_data_t& pCrashData,
);
}
- if (ret) {
- /* FIXME: be more informative */
- throw CABRTException(EXCEP_PLUGIN, "Kernel oops has not been
sent");
+ if (ret != CURLE_OK) {
+ /* FIXME: rid of std::string */
+ std::string e = ssprintf("Kernel oops has not been sent
due to %s", curl_easy_strerror(ret));
- I would use sprintf instead of ssprintf to avoid using C++ string
+ throw CABRTException(EXCEP_PLUGIN, e.c_str());
- .. and then you won't need e.c_str()
}
/* Server replies with:
* 200 thank you for submitting the kernel oops information
Jirka