我创建了一个 diff 文件。我尝试将其应用到另一个分支patch -p1 --dry-run < ~/patch_name
(我在第一个目录中 - 因此-p1
),但我得到了
补丁:**** 第 45 行的补丁格式错误:diff --FILE_LOCATION...
在出现该错误之前,已打印出该行;
checking file file_a
checking file file_b
所以,我明白这file_a, file_b
是没问题的,但我在第 45 行遇到了问题,所以我删除了第 45 行到文件末尾(我这样做了两次 - 一次在最后没有换行符,一次有)。
现在错误是
补丁:**** 第 44 行的补丁格式错误:diff --FILE_LOCATION...
这个补丁有什么问题?
这是补丁本身:
diff --git a/trunk/rf_iss/ISS/code/future/inc/params.h b/trunk/rf_iss/ISS/code/future/inc/params.h
index 1983556..16a8375 100755
--- a/trunk/rf_iss/ISS/code/future/inc/params.h
+++ b/trunk/rf_iss/ISS/code/future/inc/params.h
@@ -2348,6 +2348,7 @@ typedef UINT1 tLocalPortList [CONTEXT_PORT_LIST_SIZE];
#define MAX_SLI_SLL_NODES 1500
#define MAX_SLI_BUFF_BLOCKS 2
#define MAX_SLI_FD_ARR_BLOCKS 2
+#define MAX_SLI_WAKEUP 25
#define MAX_SLI_SDT_BLOCKS MAX_NO_OF_SOCKETS
#define MAX_SLI_RAW_HASH_NODES MAX_NO_OF_SOCKETS
#define MAX_SLI_RAW_RCV_Q_NODES MAX_NO_OF_SOCKETS
diff --git a/trunk/rf_iss/ISS/code/future/netip/fsip/udp/src/udptskmg.c b/trunk/rf_iss/ISS/code/future/netip/fsip/udp/src/udptskmg.c
index 9db6034..c5ac3ad 100755
--- a/trunk/rf_iss/ISS/code/future/netip/fsip/udp/src/udptskmg.c
+++ b/trunk/rf_iss/ISS/code/future/netip/fsip/udp/src/udptskmg.c
@@ -11,6 +11,7 @@
static VOID Udp_timer_expiry_handler PROTO ((VOID));
extern tMemPoolId gUdp4MemPoolId;
+extern INT4 gi4SelectWakeupFd;
/*-------------------------------------------------------------------+
* Function : Ip_Udp_Task_Init
*
@@ -191,6 +192,20 @@ udp_task_enqueue_to_applications_in_cxt (UINT4 u4ContextId, UINT2 u2Port,
t_UDP * pUdpHdr)
{
t_UDP_TO_APP_MSG_PARMS *pParms = NULL;
+
+ /* If queue is depleting reserved wakeupFd blocks drop packet */
+ if (pCtrlBlk->i4SockDesc != gi4SelectWakeupFd)
+ {
+ if (MemGetFreeUnits (gUdp4MemPoolId) <= MAX_SLI_WAKEUP)
+ {
+ IP_CXT_TRC (u4ContextId, UDP_MOD_TRC,
+ ALL_FAILURE_TRC | CONTROL_PLANE_TRC, UDP_NAME,
+ "Packet Discarded since memory goes over reserved wakeup fd's\n");
+ IP_RELEASE_BUF (pBuf, FALSE);
+ return IP_FAILURE;
+ }
+ }
pParms = (t_UDP_TO_APP_MSG_PARMS *) MemAllocMemBlk (gUdp4MemPoolId);
if (pParms == NULL)
diff --git a/trunk/rf_iss/ISS/code/future/sli/socket.c b/trunk/rf_iss/ISS/code/future/sli/socket.c
index 1ca5641..2ad721f 100755
--- a/trunk/rf_iss/ISS/code/future/sli/socket.c
+++ b/trunk/rf_iss/ISS/code/future/sli/socket.c
@@ -3244,6 +3244,26 @@ SliSendtoWithTrace (INT4 i4SockDesc, CONST VOID *pi1Buf, INT4 i4BufLen,
}
cpPeerSdtSock = SOCK_DESC_TABLE[i4PeerSockDesc];
+ /* check added to ensure that MAX_SLI_WAKEUP
+ * units are reserved for WakeupFD socket. This is to
+ * ensure wakeup fd is always protected such that once
+ * it gets notification, it will cleanup the filled
+ * udp queue. but wakeup fd could
+ * not be triggered because of lack of space in queue
+ * so explicitly reserve space for wakeup fd socket.
+ */
+ if (i4SockDesc != gi4SelectWakeupFd)
+ {
+ if (MemGetFreeUnits (gUdp4MemPoolId) <= MAX_SLI_WAKEUP)
+ {
+ SLI_Release_Buffer (pBufChnHdr, FALSE);
+ CpsdtSock->i1ErrorCode = SLI_EMEMFAIL;
+ SLI_ERR (SLI_EMEMFAIL);
+ GiveSliProtectSem(CpsdtSock->ProtectSemId);
+ return SLI_FAILURE;
+ }
+ }
+
/* allocate memory for UDP message from UDP4 mem pool */
pParms = (t_UDP_TO_APP_MSG_PARMS *) MemAllocMemBlk (gUdp4MemPoolId);
if (pParms == NULL)
我使用它创建了它diff
,所以我不明白它怎么会格式错误......
答案1
我最近在手动编辑补丁文件时遇到了这个问题,因为它包含一些不必要的更改。
问题出在这里(我添加了行号来说明):
@@ -191,6 +192,20 @@ udp_task_enqueue_to_applications_in_cxt (UINT4 u4ContextId, UINT2 u2Port,
1 t_UDP * pUdpHdr)
2 {
3 t_UDP_TO_APP_MSG_PARMS *pParms = NULL;
4+
5+ /* If queue is depleting reserved wakeupFd blocks drop packet */
6+ if (pCtrlBlk->i4SockDesc != gi4SelectWakeupFd)
7+ {
8+ if (MemGetFreeUnits (gUdp4MemPoolId) <= MAX_SLI_WAKEUP)
9+ {
10+ IP_CXT_TRC (u4ContextId, UDP_MOD_TRC,
11+ ALL_FAILURE_TRC | CONTROL_PLANE_TRC, UDP_NAME,
12+ "Packet Discarded since memory goes over reserved wakeup fd's\n");
13+ IP_RELEASE_BUF (pBuf, FALSE);
14+ return IP_FAILURE;
15+ }
16+ }
17
18 pParms = (t_UDP_TO_APP_MSG_PARMS *) MemAllocMemBlk (gUdp4MemPoolId);
19 if (pParms == NULL)
具体来说,问题出在“+192,20”
Patch 期望最终修补的块有 20 行长,但是如果算上 6 行上下文,加上 13 行添加,减去 0 行删除,总共只有 19 行。您会注意到,后面的行if (pParms == NULL)
恰好是第 45 行,这是错误消息中列出的行号 - 它到达了第 45 行,期望块中还有一行,但却收到了一行声明新块的内容。
如果你将第一行改为
@@ -191,6 +192,19 @@ udp_task_enqueue_to_applications_in_cxt (UINT4 u4ContextId, UINT2 u2Port,
您的补丁应该可以正确应用。
答案2
答案3
增加最大模糊因子对我来说是有效的:
patch -p1 -F 10 < file.patch