From edcaa954bab2d48b54ab3dbcbe3788dc104044dc Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Mon, 20 Dec 2010 19:54:43 +0000 Subject: [PATCH] Fix warning in sbr/folder_addmsg.c by code cleanup Clean up some rather oddly written code in folder_addmsg() so it is easier to understand for both humans and for the compiler (and the compiler thus stops complaining about an uninitialised variable). Signed-off-by: Peter Maydell --- sbr/folder_addmsg.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/sbr/folder_addmsg.c b/sbr/folder_addmsg.c index 52baa7a..a0595e6 100644 --- a/sbr/folder_addmsg.c +++ b/sbr/folder_addmsg.c @@ -20,39 +20,30 @@ int folder_addmsg (struct msgs **mpp, char *msgfile, int selected, int unseen, int preserve, int deleting, char *from_dir) { - int infd, outfd, linkerr, first_time, msgnum; + int infd, outfd, linkerr, msgnum; char *nmsg, newmsg[BUFSIZ]; char oldmsg[BUFSIZ]; struct msgs *mp; struct stat st1, st2; - first_time = 1; /* this is first attempt */ mp = *mpp; + /* should we preserve the numbering of the message? */ + if (preserve && (msgnum = m_atoi (msgfile)) > 0) { + ; + } else if (mp->nummsg == 0) { + /* check if we are adding to empty folder */ + msgnum = 1; + } else { + /* else use highest message number + 1 */ + msgnum = mp->hghmsg + 1; + } + /* * We might need to make several attempts * in order to add the message to the folder. */ - for (;;) { - /* - * Get the message number we will attempt to add. - */ - if (first_time) { - /* should we preserve the numbering of the message? */ - if (preserve && (msgnum = m_atoi (msgfile)) > 0) { - ; - } else if (mp->nummsg == 0) { - /* check if we are adding to empty folder */ - msgnum = 1; - } else { - /* else use highest message number + 1 */ - msgnum = mp->hghmsg + 1; - } - first_time = 0; - } else { - /* another attempt, so try next higher message number */ - msgnum++; - } + for (;; msgnum++) { /* * See if we need more space. If we need space at the -- 1.7.10.4