Changeset View
Changeset View
Standalone View
Standalone View
contrib/netbsd-tests/lib/libc/ssp/h_gets.c
Show All 27 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__COPYRIGHT("@(#) Copyright (c) 2008\ | __COPYRIGHT("@(#) Copyright (c) 2008\ | ||||
The NetBSD Foundation, inc. All rights reserved."); | The NetBSD Foundation, inc. All rights reserved."); | ||||
__RCSID("$NetBSD: h_gets.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $"); | __RCSID("$NetBSD: h_gets.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $"); | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#ifdef __FreeBSD__ | |||||
/* | |||||
* We want to test the gets() implementation, but cannot simply link against | |||||
* the gets symbol because it is not in the default version. (We've made it | |||||
* unavailable by default on FreeBSD because it should not be used.) | |||||
* | |||||
* This is a workaround to access gets@FBSD_1.0. | |||||
*/ | |||||
kib: Why this chunk is needed ? Esp. the compat definition. | |||||
Done Inline ActionsThis gets() test case won't link unless I can access the actual symbol. Is there another way to explicitly call gets@FBSD1.0? I thought about just dropping the test case altogether, but it seems reasonable to keep it. emaste: This gets() test case won't link unless I can access the actual symbol. Is there another way to… | |||||
Done Inline ActionsAh, so you want to test the semi-hidden libc function still ? I think you need to explain the intent in the comment somewhere. kib: Ah, so you want to test the semi-hidden libc function still ? I think you need to explain the… | |||||
char *unsafe_gets(char *); | |||||
Not Done Inline ActionsI would perhaps move the __sym_compat line up below the unsafe_gets() line and then add a blank line before the gets() wrapper function. You could then amend the last sentence in the comment perhaps to something like: * The next two lines create an unsafe_gets() function that resolves to gets@FBSD_1.0. I just find this bit of code non-obvious and think this might make it a bit more clear, but it might also be fine as-is. It is up to you. jhb: I would perhaps move the __sym_compat line up below the unsafe_gets() line and then add a blank… | |||||
char *gets(char *buf) | |||||
{ | |||||
return unsafe_gets(buf); | |||||
} | |||||
__sym_compat(gets, unsafe_gets, FBSD_1.0); | |||||
#endif | |||||
int | int | ||||
main(int argc, char *argv[]) | main(int argc, char *argv[]) | ||||
{ | { | ||||
char b[10]; | char b[10]; | ||||
(void)gets(b); | (void)gets(b); | ||||
(void)printf("%s\n", b); | (void)printf("%s\n", b); | ||||
return 0; | return 0; | ||||
} | } |
Why this chunk is needed ? Esp. the compat definition.