title: Compile error :lvalue required as left operand of assignment
body: <p>I am a beginner in Linux and C together.
  I need to run a program that I downloaded, in readme file was written that run "make" to build it`s running package. But when I ran it, I got these errors:</p>
  
  <pre><code>~/injectso-0.2$ make
  gcc -I./  -c -g -O2 -Wall  procdbg.c
  procdbg.c: In function ‘push_stack_proc’:
  procdbg.c:149:26: error: lvalue required as left operand of assignment
      (unsigned long) pvEsp -= iSize;
                            ^
  
  procdbg.c: In function ‘restore_syscall’:
  procdbg.c:244:49: error: lvalue required as left operand of assignment
            (unsigned long) ptProcStatus-&gt;regs.eip = (unsigned long) ptProcStatus-&gt;regs.eip - 2; 
                                                   ^
  make: *** [procdbg.o] Error 1
  </code></pre>
  
  <p>It seems that the casting is wrong and makes the left hand of assignment to a value except for address. This is the actual code for first error:</p>
  
  <pre><code>   void *pvEsp;
     SProcStatus tProcStatus;
  
     /* If there is no data to be pushed, exit                               */
     if (!iSize)
        return(0);
  
     /* Get the current ESP                                                  */
     read_status(&amp;(tProcStatus));
     pvEsp = (void *) SP(tProcStatus);
  
     show_debug(3, "Current ESP is %p\n", pvEsp);
  
     /* Now subtract the amount of space we need for the                     */
     /* data to be pushed                                                    */
     (unsigned long) pvEsp -= iSize;
  </code></pre>
  
  <p>I changed the faulty line to the bottom but the error still arises:</p>
  
  <pre><code>       (unsigned long *) pvEsp -= iSize;
  </code></pre>
  
  <p>Any suggestion you have?
  And I have ubuntu 14.04 i686 on VMware.</p>
  
  <h2>EDIT :</h2>
  
  <p>problem is solved from a patch that is in link in Slugonamission answer:</p>
  
  <pre><code>-   (unsigned long) pvEsp -= iSize;
  +   pvEsp -= (unsigned long) iSize;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>- (unsigned long) ptProcStatus-&gt;regs.eip = (unsigned long) ptProcStatus-&gt;regs.eip - 2; 
  +  ptProcStatus-&gt;regs.eip = (unsigned long) ptProcStatus-&gt;regs.eip - 2; 
  </code></pre>
  
  <p>But for people who wanted more information about problem, I personally dont know much about it but show you complete code of function:</p>
  
  <pre><code> /* Write a saved eip into the remote process, this                      */
     /* address must NOT be a valid page (i.e it MUST cause                  */
     /* a segfault). For fun we use 0x41414140 (not 41414141                 */
     /* since its nice to have an aligned address)                           */
     pvEip = (void *) 0x41414140;
  #if OS_LINUX &amp;&amp; CPU_IA32
     push_stack_proc(&amp;pvEip, sizeof(pvEip));
  .....
  
  
  
  /* push_stack_proc - Push specified data onto the remote                   */
  /* stack                                                                   */
  void *push_stack_proc(void *pvAddr, int iSize) {
     void *pvEsp;
     SProcStatus tProcStatus;
  
     /* If there is no data to be pushed, exit                               */
     if (!iSize)
        return(0);
  
     /* Get the current ESP                                                  */
     read_status(&amp;(tProcStatus));
     pvEsp = (void *) SP(tProcStatus);
  
     show_debug(3, "Current ESP is %p\n", pvEsp);
  
     /* Now subtract the amount of space we need for the                     */
     /* data to be pushed                                                    */
      pvEsp -= (unsigned long) iSize;                   //correct line
    //((unsigned long ) pvEsp) -= iSize;                //faulty line
  
     /* Round it to a multiple of 8 (if it isn't already)                    */
     /* (We use 8 since Sparc requires double word alignment)                */
     pvEsp = (void *) round_down((unsigned long) pvEsp, STACK_ALIGN);
  
     /* Write the ESP to the process                                         */
     SP(tProcStatus) = (unsigned long) pvEsp;
     if (!write_regs(&amp;(tProcStatus)))
        show_abort("Could not modify stack pointer in target process\n");
     read_status(&amp;(tProcStatus));
     show_debug(3, "New SP is 0x%08x\n", SP(tProcStatus));
  
     /* Now write the data itself to the remote process                      */
     if (iSize &gt; (write_proc(pvEsp, pvAddr, iSize)))
        show_abort("Could not write to remote process\n");
  
     return(pvEsp);
  }
  </code></pre>