Skip to content

Commit c29c3a0

Browse files
committed
Fix compiler warnings on macOS
This patch fixes the following compiler warnings on macOS: - The address of 'self->session' will always evaluate to 'true' - The usage of '&' for a bitwise operation Change-Id: I50c4b565f481fdb29544ac6b2a6922fad4cfb9b7
1 parent 3be9f7b commit c29c3a0

File tree

1 file changed

+15
-50
lines changed

1 file changed

+15
-50
lines changed

src/mysql_capi.c

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -650,18 +650,13 @@ MySQL_use_unicode(MySQL *self, PyObject *args)
650650
651651
@param self MySQL instance
652652
653-
@return PyInt_Type or PyNone
653+
@return PyInt_Type
654654
@retval PyInt_Type OK
655-
@retval PyNone no active session
656655
*/
657656
PyObject *
658657
MySQL_st_affected_rows(MySQL *self)
659658
{
660-
if (&self->session) {
661-
return PyLong_FromUnsignedLongLong((&self->session)->affected_rows);
662-
}
663-
664-
Py_RETURN_NONE;
659+
return PyLong_FromUnsignedLongLong((&self->session)->affected_rows);
665660
}
666661

667662
/**
@@ -671,18 +666,13 @@ MySQL_st_affected_rows(MySQL *self)
671666
672667
@param self MySQL instance
673668
674-
@return PyInt_Type or PyNone
669+
@return PyInt_Type
675670
@retval PyInt_Type OK
676-
@retval PyNone no active session
677671
*/
678672
PyObject *
679673
MySQL_st_client_flag(MySQL *self)
680674
{
681-
if (&self->session) {
682-
return PyLong_FromLong((&self->session)->client_flag);
683-
}
684-
685-
Py_RETURN_NONE;
675+
return PyLong_FromLong((&self->session)->client_flag);
686676
}
687677

688678
/**
@@ -692,18 +682,13 @@ MySQL_st_client_flag(MySQL *self)
692682
693683
@param self MySQL instance
694684
695-
@return PyInt_Type or PyNone
685+
@return PyInt_Type
696686
@retval PyInt_Type OK
697-
@retval PyNone no active session
698687
*/
699688
PyObject *
700689
MySQL_st_field_count(MySQL *self)
701690
{
702-
if (&self->session) {
703-
return PyLong_FromLong((&self->session)->field_count);
704-
}
705-
706-
Py_RETURN_NONE;
691+
return PyLong_FromLong((&self->session)->field_count);
707692
}
708693

709694
/**
@@ -713,18 +698,13 @@ MySQL_st_field_count(MySQL *self)
713698
714699
@param self MySQL instance
715700
716-
@return PyInt_Type or PyNone
701+
@return PyInt_Type
717702
@retval PyInt_Type OK
718-
@retval PyNone no active session
719703
*/
720704
PyObject *
721705
MySQL_st_insert_id(MySQL *self)
722706
{
723-
if (&self->session) {
724-
return PyLong_FromUnsignedLongLong((&self->session)->insert_id);
725-
}
726-
727-
Py_RETURN_NONE;
707+
return PyLong_FromUnsignedLongLong((&self->session)->insert_id);
728708
}
729709

730710
/**
@@ -734,18 +714,13 @@ MySQL_st_insert_id(MySQL *self)
734714
735715
@param self MySQL instance
736716
737-
@return PyInt_Type or PyNone
717+
@return PyInt_Type
738718
@retval PyInt_Type OK
739-
@retval PyNone no active session
740719
*/
741720
PyObject *
742721
MySQL_st_server_capabilities(MySQL *self)
743722
{
744-
if (&self->session) {
745-
return PyLong_FromLong((&self->session)->server_capabilities);
746-
}
747-
748-
Py_RETURN_NONE;
723+
return PyLong_FromLong((&self->session)->server_capabilities);
749724
}
750725

751726
/**
@@ -755,18 +730,13 @@ MySQL_st_server_capabilities(MySQL *self)
755730
756731
@param self MySQL instance
757732
758-
@return PyInt_Type or PyNone
733+
@return PyInt_Type
759734
@retval PyInt_Type OK
760-
@retval PyNone no active session
761735
*/
762736
PyObject *
763737
MySQL_st_server_status(MySQL *self)
764738
{
765-
if (&self->session) {
766-
return PyLong_FromLong((&self->session)->server_status);
767-
}
768-
769-
Py_RETURN_NONE;
739+
return PyLong_FromLong((&self->session)->server_status);
770740
}
771741

772742
/**
@@ -776,18 +746,13 @@ MySQL_st_server_status(MySQL *self)
776746
777747
@param self MySQL instance
778748
779-
@return PyInt_Type or PyNone
749+
@return PyInt_Type
780750
@retval PyInt_Type OK
781-
@retval PyNone no active session
782751
*/
783752
PyObject *
784753
MySQL_st_warning_count(MySQL *self)
785754
{
786-
if (&self->session) {
787-
return PyLong_FromLong((&self->session)->warning_count);
788-
}
789-
790-
Py_RETURN_NONE;
755+
return PyLong_FromLong((&self->session)->warning_count);
791756
}
792757

793758
/**
@@ -2644,7 +2609,7 @@ MySQL_fetch_row(MySQL *self)
26442609
if (field_type == MYSQL_TYPE_TINY || field_type == MYSQL_TYPE_SHORT ||
26452610
field_type == MYSQL_TYPE_LONG || field_type == MYSQL_TYPE_LONGLONG ||
26462611
field_type == MYSQL_TYPE_INT24 || field_type == MYSQL_TYPE_YEAR) {
2647-
if (field_flags && ZEROFILL_FLAG) {
2612+
if (field_flags & ZEROFILL_FLAG) {
26482613
PyTuple_SET_ITEM(result_row, i, PyLong_FromString(row[i], NULL, 10));
26492614
}
26502615
else {

0 commit comments

Comments
 (0)