Skip to content

Commit

Permalink
spool.c:parseheader() - remove unnecessary checks for NULL
Browse files Browse the repository at this point in the history
The static function imap/spool.c:parseheader() is called from only one place.

The passed parameters headname, contents and rawvalue from that place are not
NULL, so there is no need to check within parseheader() if these parameters
are NULL.
  • Loading branch information
dilyanpalauzov committed Sep 3, 2023
1 parent 7487746 commit b49020d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions imap/spool.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ typedef enum {
on error, returns < 0
*/
__attribute__((nonnull(3,4,5)))
static int parseheader(struct protstream *fin, FILE *fout,
char **headname, char **contents,
char **rawvalue,
Expand Down Expand Up @@ -291,9 +292,9 @@ static int parseheader(struct protstream *fin, FILE *fout,
if (c != EOF) prot_ungetc(c, fin);

/* and we didn't get a header */
if (headname != NULL) *headname = NULL;
if (contents != NULL) *contents = NULL;
if (rawvalue != NULL) *rawvalue = NULL;
*headname = NULL;
*contents = NULL;
*rawvalue = NULL;

return r;

Expand All @@ -303,9 +304,9 @@ static int parseheader(struct protstream *fin, FILE *fout,
/* Note: xstrdup()ing the string ensures we return
* a minimal length string with no allocation slack
* at the end */
if (headname != NULL) *headname = xstrdup(name.s);
if (contents != NULL) *contents = xstrdup(body.s);
if (rawvalue != NULL) *rawvalue = xstrdup(raw.s);
*headname = xstrdup(name.s);
*contents = xstrdup(body.s);
*rawvalue = xstrdup(raw.s);

return 0;
}
Expand Down

0 comments on commit b49020d

Please sign in to comment.