From 92dc8ab6e115c0167694cf5181399060b884e982 Mon Sep 17 00:00:00 2001 From: kettenis <> Date: Wed, 24 Mar 2010 14:47:46 +0000 Subject: [PATCH] Modify example not to use an assignment in the if statement. We shouldn't teach people bad habits! ok krw@, jmc@, dlg@, thib@ --- src/lib/libc/string/strdup.3 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/libc/string/strdup.3 b/src/lib/libc/string/strdup.3 index 5ef38e38..60a74627 100644 --- a/src/lib/libc/string/strdup.3 +++ b/src/lib/libc/string/strdup.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: strdup.3,v 1.14 2007/05/31 19:19:32 jmc Exp $ +.\" $OpenBSD: strdup.3,v 1.15 2010/03/24 14:47:46 kettenis Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)strdup.3 8.1 (Berkeley) 6/9/93 .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: March 24 2010 $ .Dt STRDUP 3 .Os .Sh NAME @@ -59,7 +59,8 @@ to an allocated area of memory containing the NUL-terminated string .Bd -literal -offset indent char *p; -if ((p = strdup("foobar")) == NULL) { +p = strdup("foobar"); +if (p == NULL) { fprintf(stderr, "Out of memory.\en"); exit(1); }