[gparted] Fix ignoring return value compiler warning
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Fix ignoring return value compiler warning
- Date: Mon, 18 Jul 2011 19:34:53 +0000 (UTC)
commit 026d0bd34b8721d941deea12128ee684b2bebaa9
Author: Curtis Gedak <gedakc gmail com>
Date: Sat Jul 16 09:19:29 2011 -0600
Fix ignoring return value compiler warning
Add code to handle situation where mkdtemp(char*) function returns
with a NULL value. Prior to this code the compiler would complain
with the following message:
error: ignoring return value of âchar* mkdtemp(char*)â, declared with
attribute warn_unused_result
src/Dialog_Rescue_Data.cc | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/src/Dialog_Rescue_Data.cc b/src/Dialog_Rescue_Data.cc
index 47c6323..7e2e22d 100644
--- a/src/Dialog_Rescue_Data.cc
+++ b/src/Dialog_Rescue_Data.cc
@@ -1,4 +1,5 @@
/* Copyright (C) 2010 Joan LledÃ
+ * Copyright (C) 2011 Curtis Gedak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,6 +23,7 @@
#include <gtkmm/stock.h>
#include <gtkmm/checkbutton.h>
#include <sstream>
+#include <cerrno>
namespace GParted
{
@@ -159,7 +161,24 @@ void Dialog_Rescue_Data::on_view_clicked(int nPart)
char tmpDir[32]=tmp_prefix;
- mkdtemp(tmpDir);
+ char * tmpDirResult = mkdtemp(tmpDir);
+ if ( tmpDirResult == NULL )
+ {
+ Glib::ustring error_txt = _("An error occurred while creating a temporary director for use as a mount point.");
+ error_txt += "\n";
+ error_txt += _("Error");
+ error_txt += ":\n";
+ error_txt += Glib::strerror( errno );
+
+ //Dialog information
+ Gtk::MessageDialog errorDialog(*this, "", true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
+ errorDialog.set_message(_("Failed creating temporary directory"));
+ errorDialog.set_secondary_text(error_txt);
+
+ errorDialog.run();
+
+ return;
+ }
Glib::ustring mountPoint=tmpDir;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]