0

I am trying to run the following command in ubuntu terminal

patch -p0 -i adjustmentFile.patch

That is giving the following error

patching file ./src/helpStructures/CastaliaModule.cc
patching file ./src/node/communication/mac/tunableMac/TunableMAC.cc
Hunk #2 FAILED at 456.
1 out of 2 hunks FAILED -- saving rejects to file ./src/node/communication/mac/tunableMac/TunableMAC.cc.rej

I tried almost all the ways suggested in the link Hunk #1 FAILED at 1. What's that mean?. However, nothing worked.

Here is my version detail

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 06 2019 17:31:41) Included patches: 1-1453

The patch file:

diff -r -u ./src/helpStructures/CastaliaModule.cc ./src/helpStructures/CastaliaModule.cc
--- ./src/helpStructures/CastaliaModule.cc  2010-12-09 09:56:47.000000000 -0300
+++ ./src/helpStructures/CastaliaModule.cc  2011-12-20 00:16:39.944320051 -0300
@@ -180,6 +180,8 @@
            classPointers.resourceManager = getParentModule()->getParentModule()->getSubmodule("ResourceManager");
        else if (name.compare("SensorManager") == 0)
            classPointers.resourceManager = getParentModule()->getSubmodule("ResourceManager");
+       else if (name.compare("Routing") == 0)
+                   classPointers.resourceManager = getParentModule()->getParentModule()->getSubmodule("ResourceManager");
        else
            opp_error("%s module has no rights to call drawPower() function", getFullPath().c_str());
         if (!classPointers.resourceManager) 
Only in ./src/helpStructures: CastaliaModule.cc~
diff -r -u ./src/node/communication/mac/tunableMac/TunableMAC.cc ./src/node/communication/mac/tunableMac/TunableMAC.cc
--- ./src/node/communication/mac/tunableMac/TunableMAC.cc   2011-03-30 02:14:34.000000000 -0300
+++ ./src/node/communication/mac/tunableMac/TunableMAC.cc   2011-12-19 23:57:43.894686687 -0300
@@ -405,6 +405,8 @@
 void TunableMAC::fromRadioLayer(cPacket * pkt, double rssi, double lqi)
 {
    TunableMacPacket *macFrame = dynamic_cast <TunableMacPacket*>(pkt);
+   macFrame->getMacRadioInfoExchange().RSSI = rssi;
+   macFrame->getMacRadioInfoExchange().LQI = lqi;
    if (macFrame == NULL){
        collectOutput("TunableMAC packet breakdown", "filtered, other MAC");
        return;
@@ -454,7 +456,8 @@
        }

        case DATA_FRAME:{
-           toNetworkLayer(macFrame->decapsulate());
+           cPacket *netPkt = decapsulatePacket(macFrame);
+           toNetworkLayer(netPkt);
            collectOutput("TunableMAC packet breakdown", "received data pkts");
            if (macState == MAC_STATE_RX) {
                cancelTimer(ATTEMPT_TX);
Only in ./src/node/communication/mac/tunableMac: TunableMAC.cc~
James Z
  • 12,209
  • 10
  • 24
  • 44
11187162
  • 57
  • 1
  • 10

1 Answers1

2

Patching takes some changes made to a file X, and applies them to a different instance of file X. That is, suppose you start with generation 1 of file X; you make changes to get generation 2-a, and someone else starts with generation 1 to make generation 2-b. Now you want to take his edits that created his generation 2-b, and apply them to your generation 2-a.

If 'his' changes clash with 'your' changes, they cannot be automatically patched.

You'll need to look at the changes being made in hunk 2.

-           toNetworkLayer(macFrame->decapsulate());
+           cPacket *netPkt = decapsulatePacket(macFrame);
+           toNetworkLayer(netPkt);

and figure out what you want the result to look like. Someone needs to know what the result is supposed to be. You can't resolve conflicts without knowledge of intent.