With Linux 5.15-prerc1 printk is defined as a macro instead of a
function ("printk: Userspace format indexing support"
33701557)
This change is causing a build failure:
.../src/rx/rx_kernel.h:62:18: error: ‘printk’ undeclared (first use in
this function); did you mean ‘_printk’?
62 | # define osi_Msg printk)(
| ^~~~~~
The definition and use of the osi_Msg and osi_VMsg macros are
unconventional and the C preprocessor is not handling the macro
expansion when printk is itself a macro.
#define osi_Msg printk)(
...
(osi_Msg "%s", x);
Change osi_Msg to a function, and simply replace osi_VMsg with vprintf
since osi_VMsg is only used at one location within user space code.
osi_Msg is implemented in 2 locations, in rx_kcommon for kernel space
and in rx_user for userspace.
Note: The unconventional definitions of osi_Msg/osi_VMsg was historical
and due to older compilers not supporting variadic macros. All of
the currently support platforms should now support variadic functions.
Change-Id: I9f015e4929f2c5120e200d2b0378871e8d1375b3
Reviewed-on: https://gerrit.openafs.org/14791
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
clock_NewTime();
if (serviceId == 0) {
- (osi_Msg
+ osi_Msg(
"rx_NewService: service id for service %s is not non-zero.\n",
serviceName);
return 0;
}
if (port == 0) {
if (rx_port == 0) {
- (osi_Msg
+ osi_Msg(
"rx_NewService: A non-zero port must be specified on this call if a non-zero port was not provided at Rx initialization (service %s).\n",
serviceName);
return 0;
* installed; if the caller was intending to
* change the security classes used by this
* service, he/she loses. */
- (osi_Msg
+ osi_Msg(
"rx_NewService: tried to install service %s with service id %d, which is already in use for service %s\n",
serviceName, serviceId, service->serviceName);
USERPRI;
}
USERPRI;
rxi_FreeService(tservice);
- (osi_Msg "rx_NewService: cannot support > %d services\n",
+ osi_Msg("rx_NewService: cannot support > %d services\n",
RX_MAX_SERVICES);
return 0;
}
extern void rxi_SendRaw(struct rx_call *call, struct rx_connection *conn,
int type, char *data, int bytes, int istack);
extern struct rx_packet *rxi_SplitJumboPacket(struct rx_packet *p);
+
+/* rx_kcommon.c / rx_user.c */
+extern void osi_Msg(const char *fmt, ...) AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
# endif /* RXK_LISTENER_ENV */
#endif /* !UKERNEL */
+void
+osi_Msg(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+#if defined(AFS_LINUX_ENV)
+ vprintk(fmt, ap);
+#else
+ vprintf(fmt, ap);
+#endif
+ va_end(ap);
+}
+
#if !defined(AFS_LINUX_ENV)
void
# if defined(AFS_AIX_ENV)
(void)((exp) || (osi_AssertFailK( #exp , __FILE__, __LINE__), 0))
#endif
-#ifdef AFS_LINUX_ENV
-# define osi_Msg printk)(
-#else
-# define osi_Msg printf)(
-#endif
-#define osi_VMsg vprintf)(
-
#define osi_YieldIfPossible()
#define osi_WakeupAndYieldIfPossible(x) rx_Wakeup(x)
*/
if (fcntl(sock, F_SETFL, FNDELAY) == -1) {
perror("fcntl");
- (osi_Msg "rxi_Listen: unable to set non-blocking mode on socket\n");
+ osi_Msg("rxi_Listen: unable to set non-blocking mode on socket\n");
return -1;
}
if (sock > FD_SETSIZE - 1) {
- (osi_Msg "rxi_Listen: socket descriptor > (FD_SETSIZE-1) = %d\n",
+ osi_Msg("rxi_Listen: socket descriptor > (FD_SETSIZE-1) = %d\n",
FD_SETSIZE - 1);
return -1;
}
if (!sfds) {
if (!(sfds = IOMGR_AllocFDSet())) {
- (osi_Msg "rx failed to alloc fd_set: ");
+ osi_Msg("rx failed to alloc fd_set: ");
perror("rx_sendmsg");
err = ENOMEM;
goto error;
if (err != EWOULDBLOCK && err != ENOBUFS)
#endif
{
- (osi_Msg "rx failed to send packet: ");
+ osi_Msg("rx failed to send packet: ");
perror("rx_sendmsg");
goto error;
}
#if !defined(AFS_NT40_ENV)
if (ntohs(port) >= IPPORT_RESERVED && ntohs(port) < IPPORT_USERRESERVED) {
-/* (osi_Msg "%s*WARNING* port number %d is not a reserved port number. Use port numbers above %d\n", name, port, IPPORT_USERRESERVED);
+/* osi_Msg("%s*WARNING* port number %d is not a reserved port number. Use port numbers above %d\n", name, port, IPPORT_USERRESERVED);
*/ ;
}
if (ntohs(port) > 0 && ntohs(port) < IPPORT_RESERVED && geteuid() != 0) {
- (osi_Msg
+ osi_Msg(
"%sport number %d is a reserved port number which may only be used by root. Use port numbers above %d\n",
name, ntohs(port), IPPORT_USERRESERVED);
goto error;
break;
}
if (code) {
- (osi_Msg "%sbind failed\n", name);
+ osi_Msg("%sbind failed\n", name);
goto error;
}
#if !defined(AFS_NT40_ENV)
(socketFd, SOL_SOCKET, SO_RCVBUF, (char *)&len2,
sizeof(len2)) >= 0);
if (!greedy)
- (osi_Msg "%s*WARNING* Unable to increase buffering on socket\n",
+ osi_Msg("%s*WARNING* Unable to increase buffering on socket\n",
name);
if (rx_stats_active)
rx_atomic_set(&rx_stats.socketGreedy, greedy);
}
void
+osi_Msg(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
+void
osi_Panic(char *msg, ...)
{
va_list ap;
va_start(ap, msg);
- (osi_Msg "Fatal Rx error: ");
- (osi_VMsg msg, ap);
+ fprintf(stderr, "Fatal Rx error: ");
+ vfprintf(stderr, msg, ap);
va_end(ap);
fflush(stderr);
fflush(stdout);
#define osi_Assert(e) opr_Assert(e)
-#define osi_Msg fprintf)(stderr,
-#define osi_VMsg vfprintf)(stderr,
-
#endif /* RX_USER_INCLUDE */