git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] fix: added new BANNED_EXPL macro for better error messages, new parameter

From
HGHG King via GitGitGadget <gitgitgadget@gmail.com>
Date
Mar 6, 2021, 00:51 UTC
Message-ID
<pull.896.git.1614991897210.gitgitgadget@gmail.com>
From: HGimself <hgmaxwellking@gmail.com>
Signed-off-by: HGimself <hgmaxwellking@gmail.com>
---
    fix: added new BANNED_EXPL macro for better error messages, has a par…
    
    
    Extend Banned Function Error Messages
    =====================================
    
    AS A NEWER USER, I WANT TO BE ABLE TO UNDERSTAND WHY CERTAIN FUNCTIONS
    ARE BANNED AS WELL AS KNOW WHAT FUNCTIONS TO USE INSTEAD.
    
    
    Changes
    =======
    
     * Added new macro named BANNED_EXPL(func, expl) which added the expl
       onto the error message
     * Used strcpy as an example
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-896%2FHGHimself%2Ffix%2Fadd-new-ban-macro-with-explanation-parameter-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-896/HGHimself/fix/add-new-ban-macro-with-explanation-parameter-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/896
 banned.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/banned.h b/banned.h
index 7ab4f2e49219..a19f0afeda79 100644
--- a/banned.h
+++ b/banned.h
@@ -9,9 +9,10 @@
  */
 
 #define BANNED(func) sorry_##func##_is_a_banned_function
+#define BANNED_EXPL(func, expl) sorry_##func##_is_a_banned_funcion_because_##expl##.
 
 #undef strcpy
-#define strcpy(x,y) BANNED(strcpy)
+#define strcpy(x,y) BANNED_EXPL(strcpy, buffer_overflow_risk)
 #undef strcat
 #define strcat(x,y) BANNED(strcat)
 #undef strncpy

base-commit: be7935ed8bff19f481b033d0d242c5d5f239ed50
-- 
gitgitgadget
Next: Junio C Hamano
Message 1 of 5 in “fix: added new BANNED_EXPL macro for better error messages, new parameter”
  1. fix: added new BANNED_EXPL macro for better error messages, new parameterHG King via GitGitGadget, Mar 6, 2021
  2. Junio C HamanoMar 7, 2021
  3. Taylor BlauMar 8, 2021
  4. Jeff KingMar 8, 2021
  5. Junio C HamanoMar 8, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.