kmheaders.cpp error message could be much more helpful

Matthew Toseland <[email protected]>
Newsgroups gmane.comp.kde.devel.kmail
Message-ID <[email protected]>
While trying to determine why kmail doesn't recognise new messages from
Maildir folders on my system, I ran into the following error message:
WARNING: Error: Failure modifying
/home/toad/Mail/.debian.directory/.debian-openoffice.index.sorted (No
space left on device?)

This is actually hardcoded almost in its entirety - "No space left on
device?" is in particular a hardcoded string. It is however caused by a
real error - the code is roughly if(fd && ferror(fd)) { complain }.

I have attached a patch to include the actual error code. Unfortunately
I haven't been able to get the ******* kdepim to compile. This is
probably my fault but I've spent several hours on it and not had much
success.

Patch is against the debian stable package source (3.5.5). May not
compile because I haven't been able to make kdepim compile. :|

_______________________________________________
KMail developers mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kmail-devel
error-message-kmheaders.cpp.diff (text/x-diff, 2.3 KB)
--- kdepim-3.5.6.dfsg.1/kmail/kmheaders.cpp	2007-05-05 02:56:43.000000000 +0100
+++ /home/toad/kdepim-3.5.6.dfsg.1/kmail/kmheaders.cpp	2007-05-04 23:25:49.000000000 +0100
@@ -2657,10 +2657,11 @@
     fwrite(&appended, sizeof(appended), 1, sortStream);
     fwrite(&discovered_count, sizeof(discovered_count), 1, sortStream);
     fwrite(&sorted_count, sizeof(sorted_count), 1, sortStream);
-    if (sortStream && ferror(sortStream)) {
+    int err = ferror(sortStream);
+    if (sortStream && err) {
         fclose(sortStream);
         unlink(QFile::encodeName(sortFile));
-        kdWarning(5006) << "Error: Failure modifying " << sortFile << " (No space left on device?)" << endl;
+        kdWarning(5006) << "Error: Failure modifying " << sortFile << " (No space left on device? " << err << ")" << endl;
         kdWarning(5006) << __FILE__ << ":" << __LINE__ << endl;
         kmkernel->emergencyExit( i18n("Failure modifying %1\n(No space left on device?)").arg( sortFile ));
     }
@@ -2697,10 +2698,11 @@
     fwrite(&appended, sizeof(appended), 1, sortStream);
     fseek(sortStream, KMAIL_MAGIC_HEADER_OFFSET + 16, SEEK_SET);
 
-    if (sortStream && ferror(sortStream)) {
+    int err = ferror(sortStream);
+    if (sortStream && err) {
         fclose(sortStream);
         unlink(QFile::encodeName(sortFile));
-        kdWarning(5006) << "Error: Failure modifying " << sortFile << " (No space left on device?)" << endl;
+        kdWarning(5006) << "Error: Failure modifying " << sortFile << " (No space left on device? " << err << ")" << endl;
         kdWarning(5006) << __FILE__ << ":" << __LINE__ << endl;
         kmkernel->emergencyExit( i18n("Failure modifying %1\n(No space left on device?)").arg( sortFile ));
     }
@@ -3313,10 +3315,11 @@
     END_TIMER(selection);
     SHOW_TIMER(selection);
     if (error || (sortStream && ferror(sortStream))) {
+    	int err = ferror(sortStream);
         if ( sortStream )
             fclose(sortStream);
         unlink(QFile::encodeName(sortFile));
-        kdWarning(5006) << "Error: Failure modifying " << sortFile << " (No space left on device?)" << endl;
+        kdWarning(5006) << "Error: Failure modifying " << sortFile << " (No space left on device? " << err << " " << error << ")" << endl;
         kdWarning(5006) << __FILE__ << ":" << __LINE__ << endl;
 
         return true;
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGO+WgA9rUluQ9pFARAoSfAKCepM7dQf4okdLRJMmoR/lYyYh2gQCaA3md
yCBCHAHadoz+rvn5Hb1Ge9U=
=rGu9
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.