snprintf() does indeed return an int. From an email Joachim Nilsson
authorlum <lum@openbsd.org>
Wed, 24 Feb 2021 13:58:46 +0000 (13:58 +0000)
committerlum <lum@openbsd.org>
Wed, 24 Feb 2021 13:58:46 +0000 (13:58 +0000)
sent to tech@ many moons ago. Sorry for the delay.

usr.bin/mg/dired.c

index 69c806f..90d9a63 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dired.c,v 1.93 2019/07/11 18:20:18 lum Exp $  */
+/*     $OpenBSD: dired.c,v 1.94 2021/02/24 13:58:46 lum Exp $  */
 
 /* This file is in the public domain. */
 
@@ -479,9 +479,9 @@ d_copy(int f, int n)
        topath = adjustname(toname, TRUE);
        if (stat(topath, &statbuf) == 0) {
                if (S_ISDIR(statbuf.st_mode)) {
-                       off = snprintf(toname, sizeof(toname), "%s/%s",
+                       ret = snprintf(toname, sizeof(toname), "%s/%s",
                            topath, sname);
-                       if (off < 0 || off >= sizeof(toname) - 1) {
+                       if (ret < 0 || ret >= sizeof(toname) - 1) {
                                dobeep();
                                ewprintf("Directory name too long");
                                return (FALSE);