title: Valgrind error: conditional jump or move depends on uninitialised value(s) - C
body: <p>I am trying to write a program that receives messages and reads them. Based on what those messages are it then prints out some text. As that is the part of the code that valgrind is warning me about, I left it there for you to see. As far as I read online, there is supposed to be an initialization problem but I do not know where.</p>
  
  <pre><code>int main(int argc, char* argv[])
  {
      int oprimek = 0;
      char name[] = "/cmdQueue";
      char msg[255];
      msg[256]='\0';
      char submsg1[5];
      submsg1[6]='\0';
      char submsg2[250];
      submsg2[251]='\0';
      int len=0;
      int x=0;
      struct mq_attr atr;
      atr.mq_maxmsg = 5; 
      atr.mq_msgsize = 255;
      oprimek = mq_open(name,O_RDWR|O_CREAT|O_EXCL,0660, &amp;atr);
      if(oprimek == -1){
          perror("error");
          mq_unlink(name);
          return -1;
      }
      time_t sek;
      int size=0;
      while(1){
      mq_getattr(oprimek,&amp;atr); 
      if(atr.mq_curmsgs&gt;0){
          size=mq_receive(oprimek, msg, atr.mq_msgsize,0);
          if(size==0){
              printf("Length is 0.");
          }else{
              len=strlen(msg);
              msg[len]='\0';
              strncpy(submsg1,msg,5);
              submsg1[5]='\0';
              if(strcmp(msg, "datum")==0){
                  time(&amp;sek);
                  printf("%s", ctime(&amp;sek));
              }
              else if(strcmp(submsg1,"izpis")==0){
                  x=0;
                  while(x&lt;len){
                      submsg2[x]=msg[5+x+1];
                      x++;
                  }
                  printf("%s\n",submsg2);
              }
              else if(strcmp(msg,"zakljuci")==0){
                  printf("Turning off!\n");
                  return 1;
              }
              else{
                  printf("Unknown message: %s \n",msg);
              }
          }
      }   
      }
      mq_close(oprimek);
      mq_unlink(name);
      return 0;
  }
  </code></pre>