Commit c65171cf authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] bt8xx: remove needless check

As reported by smatch:
	drivers/media/pci/bt8xx/dst_ca.c:323 ca_get_message() warn: this array is probably non-NULL. 'p_ca_message->msg'
	drivers/media/pci/bt8xx/dst_ca.c:498 ca_send_message() warn: this array is probably non-NULL. 'p_ca_message->msg'

Those two checks are needless/useless, as the ca_msg struct is
declared as:
typedef struct ca_msg {
        unsigned int index;
        unsigned int type;
        unsigned int length;
        unsigned char msg[256];
} ca_msg_t;

So, if the p_ca_message pointer is not null, msg will also be
not null.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 91aff0c5
...@@ -320,29 +320,27 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, ...@@ -320,29 +320,27 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message,
if (copy_from_user(p_ca_message, arg, sizeof (struct ca_msg))) if (copy_from_user(p_ca_message, arg, sizeof (struct ca_msg)))
return -EFAULT; return -EFAULT;
if (p_ca_message->msg) { dprintk(verbose, DST_CA_NOTICE, 1, " Message = [%*ph]",
dprintk(verbose, DST_CA_NOTICE, 1, " Message = [%*ph]", 3, p_ca_message->msg);
3, p_ca_message->msg);
for (i = 0; i < 3; i++) {
command = command | p_ca_message->msg[i];
if (i < 2)
command = command << 8;
}
dprintk(verbose, DST_CA_NOTICE, 1, " Command=[0x%x]", command);
switch (command) { for (i = 0; i < 3; i++) {
case CA_APP_INFO: command = command | p_ca_message->msg[i];
memcpy(p_ca_message->msg, state->messages, 128); if (i < 2)
if (copy_to_user(arg, p_ca_message, sizeof (struct ca_msg)) ) command = command << 8;
return -EFAULT; }
break; dprintk(verbose, DST_CA_NOTICE, 1, " Command=[0x%x]", command);
case CA_INFO:
memcpy(p_ca_message->msg, state->messages, 128); switch (command) {
if (copy_to_user(arg, p_ca_message, sizeof (struct ca_msg)) ) case CA_APP_INFO:
return -EFAULT; memcpy(p_ca_message->msg, state->messages, 128);
break; if (copy_to_user(arg, p_ca_message, sizeof (struct ca_msg)) )
} return -EFAULT;
break;
case CA_INFO:
memcpy(p_ca_message->msg, state->messages, 128);
if (copy_to_user(arg, p_ca_message, sizeof (struct ca_msg)) )
return -EFAULT;
break;
} }
return 0; return 0;
...@@ -494,60 +492,58 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, ...@@ -494,60 +492,58 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message,
goto free_mem_and_exit; goto free_mem_and_exit;
} }
/* EN50221 tag */
command = 0;
if (p_ca_message->msg) { for (i = 0; i < 3; i++) {
/* EN50221 tag */ command = command | p_ca_message->msg[i];
command = 0; if (i < 2)
command = command << 8;
}
dprintk(verbose, DST_CA_DEBUG, 1, " Command=[0x%x]\n", command);
for (i = 0; i < 3; i++) { switch (command) {
command = command | p_ca_message->msg[i]; case CA_PMT:
if (i < 2) dprintk(verbose, DST_CA_DEBUG, 1, "Command = SEND_CA_PMT");
command = command << 8; if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started
dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT Failed !");
result = -1;
goto free_mem_and_exit;
} }
dprintk(verbose, DST_CA_DEBUG, 1, " Command=[0x%x]\n", command); dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT Success !");
break;
switch (command) { case CA_PMT_REPLY:
case CA_PMT: dprintk(verbose, DST_CA_INFO, 1, "Command = CA_PMT_REPLY");
dprintk(verbose, DST_CA_DEBUG, 1, "Command = SEND_CA_PMT"); /* Have to handle the 2 basic types of cards here */
if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) {
dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT Failed !"); dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT_REPLY Failed !");
result = -1; result = -1;
goto free_mem_and_exit; goto free_mem_and_exit;
} }
dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT Success !"); dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT_REPLY Success !");
break; break;
case CA_PMT_REPLY: case CA_APP_INFO_ENQUIRY: // only for debugging
dprintk(verbose, DST_CA_INFO, 1, "Command = CA_PMT_REPLY"); dprintk(verbose, DST_CA_INFO, 1, " Getting Cam Application information");
/* Have to handle the 2 basic types of cards here */
if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) { if ((ca_get_app_info(state)) < 0) {
dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT_REPLY Failed !"); dprintk(verbose, DST_CA_ERROR, 1, " -->CA_APP_INFO_ENQUIRY Failed !");
result = -1; result = -1;
goto free_mem_and_exit; goto free_mem_and_exit;
}
dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT_REPLY Success !");
break;
case CA_APP_INFO_ENQUIRY: // only for debugging
dprintk(verbose, DST_CA_INFO, 1, " Getting Cam Application information");
if ((ca_get_app_info(state)) < 0) {
dprintk(verbose, DST_CA_ERROR, 1, " -->CA_APP_INFO_ENQUIRY Failed !");
result = -1;
goto free_mem_and_exit;
}
dprintk(verbose, DST_CA_INFO, 1, " -->CA_APP_INFO_ENQUIRY Success !");
break;
case CA_INFO_ENQUIRY:
dprintk(verbose, DST_CA_INFO, 1, " Getting CA Information");
if ((ca_get_ca_info(state)) < 0) {
dprintk(verbose, DST_CA_ERROR, 1, " -->CA_INFO_ENQUIRY Failed !");
result = -1;
goto free_mem_and_exit;
}
dprintk(verbose, DST_CA_INFO, 1, " -->CA_INFO_ENQUIRY Success !");
break;
} }
dprintk(verbose, DST_CA_INFO, 1, " -->CA_APP_INFO_ENQUIRY Success !");
break;
case CA_INFO_ENQUIRY:
dprintk(verbose, DST_CA_INFO, 1, " Getting CA Information");
if ((ca_get_ca_info(state)) < 0) {
dprintk(verbose, DST_CA_ERROR, 1, " -->CA_INFO_ENQUIRY Failed !");
result = -1;
goto free_mem_and_exit;
}
dprintk(verbose, DST_CA_INFO, 1, " -->CA_INFO_ENQUIRY Success !");
break;
} }
free_mem_and_exit: free_mem_and_exit:
kfree (hw_buffer); kfree (hw_buffer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment