From: b Date: Fri, 3 Jul 2020 22:12:22 +0000 (+0200) Subject: add missing NULL check X-Git-Tag: v0.1 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=670f9b12dc67e104e9bda21d4c46303fbaf78627;p=staf%2Flibstaf add missing NULL check --- diff --git a/libstaf.c b/libstaf.c index 7dc52ae..c848abb 100644 --- a/libstaf.c +++ b/libstaf.c @@ -1,7 +1,7 @@ // SilentTimer Action Figure communication library // libstaf.c // -// 27.06.2020 +// 03.07.2020 // Copyright (C) 2020 Balthasar Szczepański // // This program is free software: you can redistribute it and/or modify @@ -450,6 +450,9 @@ int stafCheckEvent (int fd, uint8_t *event) uint8_t command; uint8_t data; + if (event==NULL) + return ERR_MISSING_POINTER; + while(1) { status = stafGetFrame(fd,&command,&data,1); diff --git a/libstaf.h b/libstaf.h index cddaafb..5531cbb 100644 --- a/libstaf.h +++ b/libstaf.h @@ -1,7 +1,7 @@ // SilentTimer Action Figure communication library // libstaf.h // -// 27.06.2020 +// 03.07.2020 // Copyright (C) 2020 Balthasar Szczepański // // This program is free software: you can redistribute it and/or modify @@ -113,41 +113,41 @@ #define segment_g3 0x40000000 #define segment_h3 0x80000000 -#define segment_n0 0x00000001 -#define segment_ne0 0x00000002 -#define segment_se0 0x00000004 -#define segment_s0 0x00000008 -#define segment_sw0 0x00000010 -#define segment_nw0 0x00000020 -#define segment_mid0 0x00000040 - -#define segment_n1 0x00000100 -#define segment_ne1 0x00000200 -#define segment_se1 0x00000400 -#define segment_s1 0x00000800 -#define segment_sw1 0x00001000 -#define segment_nw1 0x00002000 -#define segment_mid1 0x00004000 - -#define segment_n2 0x00010000 -#define segment_ne2 0x00020000 -#define segment_se2 0x00040000 -#define segment_s2 0x00080000 -#define segment_sw2 0x00100000 -#define segment_nw2 0x00200000 -#define segment_mid2 0x00400000 - -#define segment_n3 0x01000000 -#define segment_ne3 0x02000000 -#define segment_se3 0x04000000 -#define segment_s3 0x08000000 -#define segment_sw3 0x10000000 -#define segment_nw3 0x20000000 -#define segment_mid3 0x40000000 - -#define dot_top 0x00000080 -#define dot_bottom 0x00008000 -#define dot_alarm 0x80000000 +#define segment_n0 segment_a0 +#define segment_ne0 segment_b0 +#define segment_se0 segment_c0 +#define segment_s0 segment_d0 +#define segment_sw0 segment_e0 +#define segment_nw0 segment_f0 +#define segment_mid0 segment_g0 + +#define segment_n1 segment_a1 +#define segment_ne1 segment_b1 +#define segment_se1 segment_c1 +#define segment_s1 segment_d1 +#define segment_sw1 segment_e1 +#define segment_nw1 segment_f1 +#define segment_mid1 segment_g1 + +#define segment_n2 segment_a2 +#define segment_ne2 segment_b2 +#define segment_se2 segment_c2 +#define segment_s2 segment_d2 +#define segment_sw2 segment_e2 +#define segment_nw2 segment_f2 +#define segment_mid2 segment_g2 + +#define segment_n3 segment_a3 +#define segment_ne3 segment_b3 +#define segment_se3 segment_c3 +#define segment_s3 segment_d3 +#define segment_sw3 segment_e3 +#define segment_nw3 segment_f3 +#define segment_mid3 segment_g3 + +#define dot_top segment_h0 +#define dot_bottom segment_h1 +#define dot_alarm segment_h3 struct StafState